Skip to content

Commit 4dae56e

Browse files
d-csclaude
andcommitted
chore(webapp): downgrade SVE/Invalid-JSON logs in api.v3.batches.items to warn
Closes the wrapper-bypass gap on TRIGGER-CLOUD-103 (Stream batch items error, 1052 events in 48h). Customer-facing 4xx paths (invalid item shape, invalid JSON in stream body) now log at warn; only the 500 fall-through escalates to Sentry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 86df8ea commit 4dae56e

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

apps/webapp/app/routes/api.v3.batches.$batchId.items.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ export async function action({ request, params }: ActionFunctionArgs) {
8888

8989
return json(result, { status: 200 });
9090
} catch (error) {
91+
// Customer-facing validation failures (invalid item shape, invalid JSON
92+
// in the streamed body). The handler returns 4xx with the message;
93+
// system handles it gracefully, no alert needed.
94+
if (error instanceof ServiceValidationError) {
95+
logger.warn("Stream batch items error", { batchId, error: error.message });
96+
return json({ error: error.message }, { status: 422 });
97+
}
98+
99+
if (error instanceof Error && error.message.includes("Invalid JSON")) {
100+
logger.warn("Stream batch items error: invalid JSON", {
101+
batchId,
102+
error: error.message,
103+
});
104+
return json({ error: error.message }, { status: 400 });
105+
}
106+
91107
logger.error("Stream batch items error", {
92108
batchId,
93109
error: {
@@ -96,14 +112,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
96112
},
97113
});
98114

99-
if (error instanceof ServiceValidationError) {
100-
return json({ error: error.message }, { status: 422 });
101-
} else if (error instanceof Error) {
102-
// Check for stream parsing errors (e.g. invalid JSON)
103-
if (error.message.includes("Invalid JSON")) {
104-
return json({ error: error.message }, { status: 400 });
105-
}
106-
115+
if (error instanceof Error) {
107116
return json({ error: error.message }, { status: 500 });
108117
}
109118

0 commit comments

Comments
 (0)