Skip to content

[codex] Fix relative URL refs with path-only root ids#3084

Closed
koxudaxi wants to merge 1 commit into
mainfrom
codex/fix-relative-url-ref-3080
Closed

[codex] Fix relative URL refs with path-only root ids#3084
koxudaxi wants to merge 1 commit into
mainfrom
codex/fix-relative-url-ref-3080

Conversation

@koxudaxi

Copy link
Copy Markdown
Owner

Summary

  • resolve relative $id values against the retrieval URL before using them as the base for relative $ref resolution
  • add resolver coverage for relative root $id plus base_url
  • add a CLI regression test for --url input with path-only $id and relative external $ref

Root Cause

When a schema was fetched via --url and declared a path-only root $id like /schemas/v1/main.schema.json, that $id replaced the retrieval URL as the reference base without first being normalized to an absolute URL. The next relative $ref was therefore resolved as a local filesystem path instead of remaining remote.

Validation

  • tox -e type
  • tox -e readme
  • tox -e cli-docs -- --check
  • tox -e config-types -- --check
  • tox -e py314-parallel -- tests/test_reference.py tests/main/jsonschema/test_main_jsonschema.py -k 'relative_root_id or root_id_differs_from_base_url or url_with_relative_root_id_resolves_relative_refs or root_id_jsonschema_with_remote_file or remote_ref'
  • tox -e py312-parallel -- tests/test_reference.py tests/main/jsonschema/test_main_jsonschema.py -k 'relative_root_id or root_id_differs_from_base_url or url_with_relative_root_id_resolves_relative_refs or root_id_jsonschema_with_remote_file or remote_ref'

Fixes: #3080

@github-actions

Copy link
Copy Markdown
Contributor

📚 Docs Preview: https://pr-3084.datamodel-code-generator.pages.dev

@codspeed-hq

codspeed-hq Bot commented Apr 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 11 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing codex/fix-relative-url-ref-3080 (dd04c13) with main (05901ff)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (05901ff) to head (dd04c13).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #3084    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           87        87            
  Lines        18247     18633   +386     
  Branches      2087      2158    +71     
==========================================
+ Hits         18247     18633   +386     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi

Copy link
Copy Markdown
Owner Author

Superseded by #3085 due to branch and PR naming policy.

@koxudaxi koxudaxi closed this Apr 14, 2026
@koxudaxi koxudaxi deleted the codex/fix-relative-url-ref-3080 branch April 14, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relative $ref does not resolve externally when using --url option

1 participant