Repository navigation
fix(cli): send the content type of raw files in oa upload - #460
Merged
M0Rf30 merged 1 commit intoNov 10, 2026
Merged
Conversation
oa upload sent every file to a raw repository as application/octet-stream: putFile falls back to it when the asset has no ContentType, and oa upload (unlike oa import, which takes the source system's type) never set one. A raw repository stores and serves that type, so a PDF, an image or a text file uploaded with oa upload downloaded instead of displaying. For raw uploads, take the type from the extension for the types Go's mime package knows without the system tables (fixed, so every machine sends the same type; some system tables map .md to text/markdown, which raw serves as a download), else detect it from the first 512 bytes like the server does for an upload without one. The contract test can now assert request headers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
|
Thanks @orcamedia, merged! |
M0Rf30
pushed a commit
that referenced
this pull request
Nov 11, 2026
GET /api/v1/search and the MCP search_artifacts tool keep the artifacts carrying a property: prop:KEY=VALUE in q, or the repeatable prop parameter for values with spaces. Exact match, all filters must hold, at most 10; q may be left out, as with flagged=true. A filter matches the id the web UI and oa store properties under (a package_files row of the same repository); docker images are left out for now. With prop no repositories are returned. Malformed filters are 400 invalid_filter (a tool error on MCP). Each filter is applied in the shape that fits how many properties match, decided by a bounded count: up to 1000 by an id array pushed into the search source, so package_files is probed by primary key (Postgres cannot push a join into the UNION ALL); more as a correlated EXISTS, which the capped search can stop early. Migration 029 adds idx_artifact_properties_key_value (key, value) INCLUDE (artifact_ref_id), built concurrently. The upgrade notes get a new "Unreleased" section with this and the oa upload content-type change of #460, which was filed under 0.23.0 although it merged after that release. Closes #459 Co-authored-by: Areef <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
oa uploadstores every file in a raw repository asapplication/octet-stream.importTarget.putFilesendssourceAsset.ContentType, orapplication/octet-streamwhen it is empty.oa importfills it from Nexus or Artifactory, butoa uploadnever sets it, and the raw handler stores the request'sContent-Type(it only sniffs when there is none). So a PDF, an image or a Markdown file uploaded withoa uploaddownloads instead of displaying, because raw only displays images, PDF andtext/plaininline.Reproduced against a 0.21.0 server, same files:
oafrom mainbrief.pdfapplication/octet-streamapplication/pdfnotes.mdapplication/octet-streamtext/plain; charset=utf-8Fix
For raw uploads only,
uploadCIFilesets the asset's content type (internal/oacli/upload_content_type.go):mimepackage knows without the system tables (.css,.html,.js,.json,.pdf,.svg,.xml,.wasm, PNG/JPEG/GIF/WebP/AVIF). It's a fixed table rather thanmime.TypeByExtension, so every machine sends the same type: system tables differ, and some map.mdtotext/markdown, which raw would serve as a download.http.DetectContentType, exactly what the server does for an upload without aContent-Type. The file is rewound, and the digest check still verifies what was stored.Maven, Ivy and sbt uploads are unchanged.
Tests
TestContractCIUploadRawContentType: a.PDF(case-insensitive extension), a.cssthat sniffing would calltext/plain, a.mdsniffed as text, and an unknown binary; each asserts theContent-Typeof the PUT and that the whole file was sent. All but the binary fail without the fix (they arrive asapplication/octet-stream).headercheck on recorded calls for this.Docs:
docs/integrations/ci.md(supported formats) and an entry in the "Unreleased" upgrade notes. Files uploaded before keep their stored type.Checked locally:
make check,go test -race ./internal/oacli/, the slim build, the unit suite with-race, and the before/after upload above against a local server.🤖 Generated with Claude Code