fix: add HTTP response status validation to fetch() calls - #1391
Raushankumar0720 wants to merge 2 commits into
Conversation
Multiple fetch() calls across the codebase did not check response.ok before processing the response body. Since the JavaScript fetch() API does not throw on HTTP error statuses (e.g. 404, 500), the application silently loaded error pages as if they were valid AsyncAPI documents, causing confusing parser errors. This commit adds response.ok checks to all 4 affected fetch() calls: - editor.service.tsx: switchToFile() and importFromURL() - app.service.ts: fetchResource() - parser.service.ts: createRemoteTrackingResolver() Closes asyncapi#1390
🦋 Changeset detectedLatest commit: aa49fef The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for asyncapi-studio-design-system ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for modest-rosalind-098b67 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
|
|
Hi maintainers! Thank you so much for your time and guidance! |



Description
Multiple
fetch()calls across studio services lackedresponse.okstatus validation before reading the response body. Becausefetch()does not reject on HTTP error status codes (such as 404 Not Found or 500 Internal Server Error), failed network requests were silently passed into YAML/JSON parsers as HTML error pages, resulting in confusing syntax errors.This PR adds explicit HTTP response validation across:
EditorService.switchToFile()andEditorService.importFromURL()ApplicationService.fetchResource()ParserService.createRemoteTrackingResolver()Behavior Comparison
SyntaxError: Unexpected token '<'Failed to fetch from URL (HTTP 404: Not Found)Test Verification
Added unit tests in
apps/studio/src/services/tests/editor-http-validation.test.tsverifying error handling for 200, 404, and 500 status codes:Related issue(s)
Resolves #1390