Fix file_object_content filters 404ing due to wrong URL prefix#956
Merged
gmazoyer merged 2 commits intoinfrahub-developfrom Apr 22, 2026
Merged
Fix file_object_content filters 404ing due to wrong URL prefix#956gmazoyer merged 2 commits intoinfrahub-developfrom
gmazoyer merged 2 commits intoinfrahub-developfrom
Conversation
The SDK constructed URLs under /api/files/* for the three file_object_content* Jinja2 filters, but the Infrahub backend serves these endpoints under /api/storage/files/*. Every call 404ed. Updated all six URLs (async + sync) in object_store.py to the correct prefix. Added happy-path unit tests for file_object_content_by_id and file_object_content_by_hfid (string and list forms) so similar contract drift with the backend router is caught in CI. Fixes #954
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## infrahub-develop #956 +/- ##
====================================================
+ Coverage 81.11% 81.19% +0.08%
====================================================
Files 134 134
Lines 11314 11315 +1
Branches 1693 1693
====================================================
+ Hits 9177 9187 +10
+ Misses 1594 1585 -9
Partials 543 543
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
gmazoyer
approved these changes
Apr 22, 2026
Contributor
gmazoyer
left a comment
There was a problem hiding this comment.
Nice catch. I don't think you need the changelog record though, since this is still unreleased code, this would appear in the changelog as a fix for something introduced in the same release.
The bug was introduced in the same release cycle, so a changelog record would appear as a fix for something that was never released.
Deploying infrahub-sdk-python with
|
| Latest commit: |
6fe555a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://84958bda.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://fix-issue-954-file-object-ur.infrahub-sdk-python.pages.dev |
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.
Why
The three
file_object_content*Jinja2 filters shipped in #889 and #904 are 404ing at runtime. The SDK hardcodes URLs under/api/files/*, but the Infrahub backend routes those endpoints under/api/storage/files/*. Every call tofile_object_content,file_object_content_by_id, orfile_object_content_by_hfidraisesJinjaFilterError: Client error '404 Not Found'and the artifact goes toError.Goal: restore the three filters to working order and add end-to-end-shaped unit tests so a URL contract drift like this one trips CI next time.
Non-goals: not changing the backend router surface, not adding new filter variants, not touching the computed-attribute gating.
Closes #954
What changed
file_object_content,file_object_content_by_id, andfile_object_content_by_hfidnow return the actual file content instead of raising a 404 wrapper.infrahub_sdk/object_store.pyprefixed with/api/storage/files/(async + sync). No other behaviour inObjectStorechanged.FILE_BY_STORAGE_ID_URLmock constant; added two new constantsFILE_BY_ID_URLandFILE_BY_HFID_URL; added three happy-path test cases forfile_object_content_by_id,file_object_content_by_hfid(string argument), andfile_object_content_by_hfid(list argument). The existing missing-kind, auth-error, and binary-content tests still cover their respective paths.How to review
infrahub_sdk/object_store.py: six one-line URL changes on lines 105/110/116/191/196/202. Trivial.tests/unit/sdk/test_infrahub_filters.py: the new happy-path tests at the bottom ofTestClientDependentFiltersare the interesting bits — note they hit per-filter URLs that match the new SDK paths 1:1.changelog/954.fixed.md: towncrier fragment.The bug was introduced in the original filter PRs (#889, #904) and has been present on every branch since.
git diff 44a7ccc..origin/infrahub-develop -- infrahub_sdk/object_store.pyreturns empty — the wrong URLs never changed.How to test
All should pass. The three new happy-path tests (
test_file_object_content_by_id_happy_path,test_file_object_content_by_hfid_happy_path_string,test_file_object_content_by_hfid_happy_path_list) each assert the SDK hitshttp://mock/api/storage/files/...— if the URL regresses, these fail immediately.End-to-end reproduction (against a live Infrahub 1.9 stack)
Start an Infrahub 1.9 instance per the usual
invoke demo.startflow. Grab the admin token (default06438eb2-8019-4776-878c-0941b1f1d1ecin dev builds) and set:1. Load a schema with a
TestingFileBlobnode inheriting fromCoreFileObject:Load it:
2. Upload a file object via the GraphQL multipart mutation:
Note the returned
id(node UUID),hfid[0](blob_a), andstorage_id.value— you'll plug these into the templates below.3. Create a
TestingPersonschema + data to act as the artifact target:4. Prepare a Git repo with three templates exercising each filter variant. Inside a worker container (or any directory reachable by Infrahub as a git remote):
Substitute the real storage_id / node id into
by_sid.j2andby_id.j2before committing.5. Register the repo:
Wait ~15 seconds for the artifact pipeline to run.
6. Observe results:
by-sid/by-id/by-hfidartifacts have statusError. Worker logs containFilter 'file_object_content*': failed to retrieve content ... Client error '404 Not Found' for url 'http://server:8000/api/files/...'.Ready. Fetching their content returns e.g.[by_sid] hello from blob A. No 404 errors anywhere in worker logs.Quick direct HTTP verification independent of the filters:
Impact & rollout
JinjaFilterErrorfrom these filters will now succeed.Checklist
changelog/954.fixed.md)