Repository navigation
Pin down that external vocabulary served as octet-stream parses - #1845
Closed
michielbdejong wants to merge 1 commit into
Closed
michielbdejong wants to merge 1 commit into
michielbdejong wants to merge 1 commit into
Conversation
GitHub Pages serves the shared ontology's extensionless JSON-AD files as `application/octet-stream`. None of the external fetch paths looks at the Content-Type: the browser client, the server behind `/path`, and the server's own `fetch_resource` all go by the body. JSON-AD parses under any type, and HTML or binary is refused under any type because it is not JSON. These tests keep it that way, since a Content-Type check would break the shared ontology silently: - Unit stubs serve terms as `application/octet-stream`, like Pages, and the client is checked on octet-stream, text/plain and a missing type, and refuses HTML and binary served as octet-stream. - The integration test adds a direct fetch from the octet-stream stub, and HTML under that type is refused both directly and through the proxy. - A Rust test covers `fetch_resource` on a loopback server for the same three cases. A strict `json` Content-Type check, added temporarily, failed each of them. Refs #1837 #1838 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joepio
added a commit
that referenced
this pull request
Sep 26, 2026
Member
|
This PR's own commit (fa72d4c) landed on develop in 2a17979 via the combined batch #1854, so I'm closing it. The other commits on this branch belong to #1842, which stays open. Generated by Claude Code |
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.
Refs #1837 #1838
Stacked on #1841.
GitHub Pages serves the shared ontology (
https://ontola.github.io/atomic-plugins/ontology/...) asapplication/octet-stream, because the files have no extension. This PR checks every path that fetches external resources for that case.No code change was needed. None of the three paths looks at the Content-Type. Each one goes by the body:
Client.fetchResourceHTTP(browser/lib/src/client.ts)JSON.parse+ the JSON-AD parser/pathproxy fallback (#1841)server/src/plugins/path.rs→get_path→fetch_resourceapplication/ad+jsonitselffetch_resource/fetch_body_with_client(lib/src/client/helpers.rs)parse_json_ad_stringSo JSON-AD parses under any type, and HTML or binary data is refused under any type because it isn't JSON. This PR only adds tests, so that a future Content-Type check can't silently break the shared ontology.
Tests
browser/lib/src/vocab-proxy-fallback.test.ts: the stubbed vocabulary host now answersapplication/octet-streamlike Pages; the proxy answersapplication/ad+json. New cases check that the client accepts JSON-AD served as octet-stream, astext/plainand with no Content-Type, and refuses HTML (as octet-stream and astext/html) and binary data served as octet-stream.browser/lib/tests/vocab-proxy.integration.test.ts(real server): the stub already served octet-stream. Added a direct fetch from it, and HTML served as octet-stream refused both directly and through/path.lib/src/client/helpers.rscontent_type_tests:fetch_resourceagainst a loopback server, where JSON-AD as octet-stream is accepted and HTML or PNG bytes as octet-stream are refused.Mutation check. Since there was nothing to fix, "fails before" was shown by temporarily adding a strict
content-type contains jsoncheck:text/plainand no-type unit cases and the direct integration case.fetch_body_with_client, it failed the Rust accept test and the proxied and fallback integration cases.All passed again after the check was removed.
Runs:
browser/libvitest: 1040 passed.cargo test -p atomic_lib --features db-redb --lib: 655 passed. The one failure,startup_compaction_shrinks_a_bloated_store_and_keeps_every_resource, is flaky under load and passes alone.cargo test -p atomic-server --lib: 270 passed.-D warnings, oxlint/oxfmt and tsc are clean.Live check
https://ontola.github.io/atomic-plugins/ontology/v1is already live:200,content-type: application/octet-stream,access-control-allow-origin: *, and a preflight gets405.classes/event-v1is also200octet-stream.ontology/v1andclasses/event-v1through@tomic/lib'sClient, both directly and through the server's signed/path. All four succeeded with the right subject.🤖 Generated with Claude Code