Repository navigation
fix(model): report malformed GGUF and Safetensors headers as invalid_format through ParseFailure - #10667
Merged
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Base automatically changed from
refactor/rust-auditable-parse-failure
to
main
November 14, 2026 20:28
Contributor
[Low impact] The PR appears safe to merge; no actionable failures were found. SummaryReplaces
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[GGUF and Safetensors parsers] --> B[ParseFailureError]
B --> C[ModelArtifactProvider]
C --> D[Malformed: file_format_rejected]
C --> E[Unsupported: unsupported_target]
C --> F[Known model limit: resource_constraint]
Reviews (1) · Last reviewed commit: "refactor(model): report GGUF and Safeten..." · Reviewed by Greptile |
…the shared mapping Malformed and truncated GGUF and Safetensors headers now take the shared ParseFailure mapping (invalid_request, invalid_format on path) instead of the model provider's own BinaryTargetError file_format_rejected. Unsupported forms stay unsupported_target and model allowances keep their resource-constraint recovery.
morluto
force-pushed
the
refactor/model-parse-failure
branch
from
November 14, 2026 20:33
33b1da4 to
baacee6
Compare
11 tasks
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
GGUF and Safetensors header parsing now reports failures through the shared ParseFailure algebra (format
model).ModelFormatFailure, itsformat | unsupported | capacitykinds, and theTypeErrorguards that checked its constructor arguments are deleted.limits. The limit name is the existingModelCapacityLimitand the maximum is the producing allowance.target_unavailable/unsupported_target(BinaryTargetError, constraintfile_format_rejected) toinvalid_request/invalid_inputwith issue{ path: ["path"], reason: "invalid_format" }, through the sharedparseFailureAnalysisErrormapping. This follows the maintainer decision (2026-11-14) that approved admission and error-category changes, matching fix(gpu): report malformed GPU containers as invalid_format #10644 for GPU containers.parser-json-parsedrops by 2 forsrc/model/ModelFormat.ts.#10652 (which added the guard) is merged; this branch is rebased on
main. Sibling of #10664 and #10665. Part of plan W7 (parser kernel).Problem and expected behavior
ModelFormatFailurerestated the ParseFailure algebra with its own spellings:formatfor malformed andcapacityfor limit. A second field,limit, was valid only for one kind and was checked at runtime with plainTypeErrorthrows.Expected:
failure, so they need no runtime check.modelCapacityLimitOf.Change and scope
src/model/ModelFormat.ts:MODEL_FORMAT.modelCapacityFailure(limit, detail)builds thelimitfailure. Its maximum comes frommodelCapacityReportedLimits, so the value has one owner.modelCapacityLimitOfrecovers theModelCapacityLimitfrom a failure.rejectModelandrejectPicklethrowmalformedInputandunsupportedInput.GgufHeader.ts,SafetensorsHeader.ts,ModelHeaderReader.tsandModelArtifactProvider.tsthrow through those helpers.ModelArtifactProvider.ts:modelCapacityLimitOf) →resource_constraintwith the same reported limits and recovery;parseFailureAnalysisError: malformed/truncated →invalid_formatonpath; unsupported (PyTorch pickle) →unsupported_target, unchanged.docs/model-artifacts.mdstates the new category.Not included:
file_format_rejectedproducers are unchanged.Contract and boundary impact
Semantic owner and earliest changed stage: the model header parsers produce the failure.
ModelArtifactProviderremains the one translation.Contribution scope fit and linked maintainer decision: maintainer decision 2026-11-14 approved error-category changes where needed (malformed →
invalid_format).CLI and MCP/tool-catalog contract: malformed/truncated model headers change public code and category as above (CLI exit code stays 1). Unsupported and capacity refusals, their messages, reported limits and recovery are unchanged. Tool schemas unchanged.
Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: partial-progress handling is unchanged.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Evidence and regression coverage
tests/boundary/model/modelArtifact.test.ts(malformed cases assertAnalysisInputErrorwithinvalid_formatonpath; the header-allowance case assertsfailure: { kind: "limit", format: "model", limit: { name: "header-bytes", maximum: 100_000_000 } }) andtests/acceptance/modelArtifactCli.test.ts(CLI and MCP malformed refusals).inspect_model_artifacton a Safetensors file whose data offsets are outside the file:{"code":"invalid_request","category":"invalid_input","details":{"operation":"inspect_model_artifact","issues":[{"path":["path"],"reason":"invalid_format","message":"Selected artifact <path>: Declared extent is outside the file"}]}}{"code":"target_unavailable","category":"unsupported_target","details":{"constraint":"file_format_rejected", ...}}).Validation performed
npm run test:focused -- tests/boundary/model/modelArtifact.test.ts tests/acceptance/modelArtifactCli.test.ts tests/boundary/mcp/modelArtifactPartialReadFailure.test.ts tests/boundary/model/modelArtifactPartialCancellation.test.ts tests/process-global/modelHostReadFailure.test.ts tests/acceptance/formatSpecificCallerPathCli.test.ts: 6 files, 172 tests passed.npm run test:focused -- tests/boundary/model/modelArtifact.test.ts(143 passed) andnpm run test:focused -- tests/acceptance/modelArtifactCli.test.ts(16 passed);npm run docs:checkpassed;node scripts/verify/architecture-guards.mjspassed.node scripts/verify/architecture-guards.mjs --shrink-baselines: passed and lowered both baselines.npm run check:fast: typecheck and lint passed.Compatibility, safety, and release
target_unavailable/file_format_rejectedfor malformed model headers now seeinvalid_request/invalid_format. Approved category change; not marked breaking, consistent with fix(gpu): report malformed GPU containers as invalid_format #10644.ModelFormatFailurewas internal.Author readiness
Human owner:
Before merge
type(scope): outcome.