Repository navigation
fix(multipart): honor declared part encodings - #194
Merged
Merged
Conversation
Signed-off-by: samzong <samzong.lu@gmail.com>
Contributor
Merging this PR will improve performance by 76.36%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | BenchmarkBuildFlat |
2.2 ms | 1 ms | ×2.1 |
| ⚡ | yaml |
4.9 ms | 2.5 ms | +93.62% |
| ⚡ | BenchmarkFormatTableInferredColumns |
1,102.2 µs | 611.3 µs | +80.3% |
| ⚡ | large |
2.2 ms | 1.2 ms | +79.58% |
| ⚡ | large |
1,552.8 µs | 870.3 µs | +78.43% |
| ⚡ | json-large |
3.4 ms | 1.9 ms | +78.02% |
| ⚡ | yaml-large |
14.3 ms | 8.1 ms | +77.62% |
| ⚡ | table |
710.6 µs | 403.2 µs | +76.23% |
| ⚡ | miss |
3.4 ms | 2 ms | +76.13% |
| ⚡ | hit |
3.5 ms | 2 ms | +75.77% |
| ⚡ | small |
137.2 µs | 78.9 µs | +73.79% |
| ⚡ | small |
114 µs | 65.7 µs | +73.41% |
| ⚡ | BenchmarkCatalogJSON |
2.8 ms | 1.6 ms | +72.78% |
| ⚡ | large |
2.3 ms | 1.3 ms | +72.56% |
| ⚡ | json |
1,216.5 µs | 705.5 µs | +72.42% |
| ⚡ | BenchmarkParseNormalize |
7.1 ms | 4.1 ms | +72.36% |
| ⚡ | large |
1,542 µs | 896.3 µs | +72.04% |
| ⚡ | BenchmarkFindCatalogCommand |
7.8 µs | 4.6 µs | +70.31% |
| ⚡ | small |
178.8 µs | 105.8 µs | +69.04% |
| ⚡ | json-small |
241.3 µs | 145.3 µs | +66.12% |
| ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/multipart-part-encoding (e2390bc) with main (acb5b7f)
…coding Signed-off-by: samzong <samzong.lu@gmail.com> # Conflicts: # docs/contracts.md # internal/codegen/render/skill_test.go # internal/lathecmd/lathecmd_test.go # pkg/runtime/catalog_projection.go # pkg/runtime/catalog_schema.go # pkg/runtime/spec.go
samzong
marked this pull request as ready for review
October 3, 2026 19:26
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.
Summary
Closes #133.
Closes #135.
type: fileand empty{}schemas become file parts. Strings, numbers, integers and booleans become typed text parts. Objects become one JSON text part. Arrays of scalars or files become repeated parts with the same name.encoding.<property>.contentTypeis honored per part. A list or wildcard is resolved against the sniffed media type of each file. Invalid elements and header-breaking text are dropped at codegen. File parts always sendContent-Type. Text parts send it only when the selected type is not exactlytext/plain.application/octet-stream. Swagger 2type: filekeeps the previous extension-based guess.$refproperty, a single-allOfwrapper around a$ref, and anallOfof object body schemas are resolved and merged into one set of part flags. Reference resolution is bounded and cycle-safe. An unresolved or cyclic reference is reported as unsupported and never becomes a file part.oneOf/anyOfonly, an unresolved reference) are omitted. They are listed in the catalog asbody.unsupported_fieldsand in the generated Skill reference.--file,--setand--set-str.Content-Dispositionnames and filenames escape\,", CR and LF, matching the current Gomime/multipartrule. Unsupported property names and part content types are escaped in generated Skill Markdown.Verification
make checkpassed.go test -race ./pkg/runtime/... ./internal/codegen/... ./internal/lathecmd/...passed.Wire tests parse real multipart requests. They cover typed text parts, repeated array parts, JSON object parts, and declared, wildcard and listed part content types. They also check that a missing required file fails before auth, that
--setis rejected, and thatContent-Dispositionescapes CR/LF.Codegen tests cover:
$ref,allOfand merged bodies;unsupported_fields;In a scratch copy of the petstore example, a local server received:
image/pngfor a.pngfile declared asimage/png, image/jpeg;image/giffor a.giffile andapplication/octet-streamfor a.txtfile declared asimage/*;application/jsonfor an object part;A missing required file exited with code 2, and
--dry-runomitted the multipart body.A scratch petstore regeneration built, and
__lathe verify --jsonreturnedok: true.An independent review exercised the staged diff over several rounds. Its findings were fixed and re-verified.
Not verified: interoperability with server frameworks other than Go
net/httpmultipart parsing.Compatibility
runtime.SchemaVersion22 andruntime.CatalogSchemaVersion29. Regenerate downstream CLIs.flags[].content_typefor multipart flags andbody.unsupported_fields.int64,boolor repeatable values). Multipart commands lose--file,--setand--set-str.application/octet-streaminstead of a type guessed from the file extension.Checklist
internal/generated/,.cache/, and ad-hocskills/<cli-name>/directories is not committed.