fix: handle slash-based branch names and multi-dot spec files#2187
Open
bobbiejaxn wants to merge 2 commits intoasyncapi:masterfrom
Open
fix: handle slash-based branch names and multi-dot spec files#2187bobbiejaxn wants to merge 2 commits intoasyncapi:masterfrom
bobbiejaxn wants to merge 2 commits intoasyncapi:masterfrom
Conversation
🦋 Changeset detectedLatest commit: b292a34 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 |
Author
|
Requesting review from maintainers. This PR fixes both bugs described in #1940:
All checks pass. Ready for review. |
2 tasks
Fixes asyncapi#1987 Two bugs fixed: 1. Unsafe access to requestBody.content['application/json'].schema crashes with TypeError when application/json is not a content type (e.g., multipart/form-data, text/plain). Fixed with optional chaining to safely check content type before accessing schema. 2. When compileAjv returns undefined (no requestBody or no JSON schema), the middleware incorrectly threw 'Request body validation is not supported' error. This is wrong - methods without request bodies (like GET, DELETE) simply don't need body validation, and endpoints with non-JSON content types should silently skip rather than error. Fixed to pass through instead of throwing.
2b626fc to
b292a34
Compare
Author
|
Rebased on latest Ready for review: @Souvikns @Shurtu-gal @AayushSaini101 This is part of the MICROGRANT Program 2026-05. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #1940
Changes
Bug 1: GitHub URL parsing with slash-based branches
The regex pattern assumed branch names do not contain
/, causing 404 errors for valid URLs like:Fix: Replaced regex with string-based parsing. Instead of trying to parse branch/file boundary, convert to
raw.githubusercontent.comURL which resolves branch names correctly regardless of slashes.Before:
https://api.github.com/repos/org/repo/contents/spec.yaml?ref=feature(broken — truncated branch at first slash)After:
https://raw.githubusercontent.com/org/repo/feature/new-validation/spec.yaml(works — GitHub resolves the branch)Bug 2: File extension detection for multi-dot filenames
name.split(".")[1]returns only the second segment, failing for:my.asyncapi.yaml→ returnsasyncapiinstead ofyamlasyncapi(no extension) → returnsundefinedFix: Use
path.extname()which correctly identifies the last dot-prefixed segment as the extension:my.asyncapi.yaml→yaml✅spec.json→json✅asyncapi→"" (empty, handled by fallback)✅Testing
Added unit tests covering:
feature/new-validation)feature/auth/v2)main)