fix: resolve GitHub URL parsing and request body validation bugs#2151
Open
jshaofa-ui wants to merge 2 commits intoasyncapi:masterfrom
Open
fix: resolve GitHub URL parsing and request body validation bugs#2151jshaofa-ui wants to merge 2 commits intoasyncapi:masterfrom
jshaofa-ui wants to merge 2 commits intoasyncapi:masterfrom
Conversation
- Fix GitHub blob URL parsing to support branches with slashes
(e.g., feature/new-validation) by using heuristic branch detection
- Fix file extension detection for multi-dot filenames
(e.g., my.asyncapi.yaml) by using split('.').pop() instead of [1]
- Fix request body validation skipping for non-JSON content types
by iterating through all available content types
Fixes asyncapi#1940
Fixes asyncapi#1987
🦋 Changeset detectedLatest commit: 58b91c8 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
|
🔧 Changeset added! Added to trigger version bump for @asyncapi/cli (patch). This PR fixes two bugs:
CI checks pass (SonarQube Quality Gate ✅). Ready for review! 🙏 |
|
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.



Summary
This PR fixes two bugs identified in the MICROGRANT Program 2026-05:
Bug #1940: CLI fails for GitHub URLs with slash-based branches and multi-dot spec files
Problem 1: GitHub URL Parsing
https://github.com/org/repo/blob/feature/new-validation/spec.yamlfailed with 404Problem 2: File Extension Detection
name.split('.')[1]which only gets the second segmentmy.asyncapi.yamlwere rejected (got 'asyncapi' instead of 'yaml')split('.').pop()to get the last segmentBug #1987: Request body validation skipped for some paths or HTTP methods
Problem: The
compileAjvfunction only checkedapplication/jsoncontent type. Paths using other content types (application/xml, etc.) had validation silently skipped.Fix: Iterate through all available content types in
requestBody.contentand use the first one with a valid schema.Files Changed
src/domains/services/validation.service.ts- GitHub URL parsing fixsrc/domains/models/SpecificationFile.ts- File extension detection fixsrc/apps/cli/commands/new/file.ts- File extension detection fixsrc/apps/api/middlewares/validation.middleware.ts- Multi-content-type supportTesting
Related to: #2125 (MICROGRANT Program 2026-05)