fix: handle empty targetLocation in reference resolution for in-memory documents - #42
Merged
TristanSpeakEasy merged 1 commit intoSep 4, 2025
Conversation
Contributor
📊 Test Coverage ReportCurrent Coverage: Coverage Change: ✅ No change Coverage by Package
Generated by GitHub Actions |
TristanSpeakEasy
deleted the
fix/empty-target-location-reference-resolution
branch
September 4, 2025 03:37
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.
Fix: Handle empty targetLocation in reference resolution for in-memory documents
Problem
The reference resolution system was failing when
targetLocationwas an empty string, which commonly occurs when dealing with in-memory documents (uploaded files, database content, etc.) that don't have a physical file path.The issue occurred in two places:
resolveAbsoluteReferenceUncached()- calledutils.ClassifyReference("")which returns an error for empty stringsResolve()- explicitly checked for emptytargetLocationand returned "target location is required" errorSolution
targetLocationis empty, default it to"."(current directory) which is the logical default for relative reference resolutionutils.ClassifyReference(targetLocation)call to the top ofresolveAbsoluteReferenceUncached()to avoid calling it twiceChanges
Core Changes
references/resolution_cache.go: FixedresolveAbsoluteReferenceUncached()to handle empty targetLocation and eliminate duplicationreferences/resolution.go: FixedResolve()to handle empty targetLocationTest Updates
references/resolution_cache_test.go: Added comprehensive tests for empty targetLocation scenariosreferences/resolution_test.go: Updated test to reflect new behaviorjsonschema/oas3/resolution_test.go: Removed problematic test that was no longer relevantTest Coverage
Added tests covering:
"."Backward Compatibility
✅ Fully backward compatible - all existing functionality continues to work as before. The change only affects the previously failing case of empty
targetLocation.Quality Assurance