-
Notifications
You must be signed in to change notification settings - Fork 145
fix(gateway): guard non-object video upstream JSON #2785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2714,7 +2714,15 @@ async function fetchUpstreamJson( | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (text.length > 0) { | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| body = JSON.parse(text) as Record<string, unknown>; | ||||||||||||||||||||||||||||
| const parsed: unknown = JSON.parse(text); | ||||||||||||||||||||||||||||
| body = | ||||||||||||||||||||||||||||
| typeof parsed === "object" && parsed !== null | ||||||||||||||||||||||||||||
| ? (parsed as Record<string, unknown>) | ||||||||||||||||||||||||||||
| : { | ||||||||||||||||||||||||||||
|
Comment on lines
+2719
to
+2721
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exclude arrays in the parsed-body guard to preserve response contract. On Line 2719, the object check still accepts arrays ( Suggested fix- body =
- typeof parsed === "object" && parsed !== null
+ body =
+ typeof parsed === "object" &&
+ parsed !== null &&
+ !Array.isArray(parsed)
? (parsed as Record<string, unknown>)
: {
error: {
message: text,
},
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| error: { | ||||||||||||||||||||||||||||
| message: text, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||
| body = { | ||||||||||||||||||||||||||||
| error: { | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When AtlasCloud's media upload responds with a valid JSON string containing a URL, such as
"https://...", this branch now wraps the parsed string in{ error: { message: text } }instead of returning the string.uploadAtlasCloudMediaimmediately passes this value toextractAtlasCloudUploadedMediaUrl, which has an explicit top-level string URL case, so those uploads regress from succeeding toAtlasCloud media upload did not return a usable URL; the null crash guard should not discard string primitives that existing extraction logic can handle.Useful? React with 👍 / 👎.