Skip to content

fix: return validation errors for malformed metadata - #111

Draft
sunruize93-cmyk wants to merge 1 commit into
MoonshotAI:mainfrom
sunruize93-cmyk:codex/fix-metadata-validation-110
Draft

sunruize93-cmyk wants to merge 1 commit into
MoonshotAI:mainfrom
sunruize93-cmyk:codex/fix-metadata-validation-110

Conversation

@sunruize93-cmyk

Copy link
Copy Markdown

Fixes #110.

Summary

  • Return structured request-validation errors for malformed metadata dtype and shape values instead of leaking TypeError as HTTP 500.
  • Keep valid metadata serialization and the public interface unchanged; real backend errors still return HTTP 500.
  • Add CPU API regressions for invalid inputs, exact field locations, and backend RuntimeError/TypeError/ValueError controls. Exception conversion is limited to the metadata validators.

Validation

Tested at b855f6f9d20bebb6d5664248164e01e7d995fe4e, based on official main 84631a24f36349435f29cc9b305aa068bed87978.

Both dependency sets used Python 3.12.13 and PyTorch 2.14.1:

FastAPI Pydantic HTTPX API tests CPU suite
0.143.2 2.14.1 0.28.1 18 passed 118 passed, 1 skipped, 12 GPU tests deselected
0.115.0 2.9.2 0.27.2 18 passed 118 passed, 1 skipped, 12 GPU tests deselected
  • The same new API tests against unmodified main: 8 failed, 10 passed. The failures were HTTP 500 versus expected 422.
  • Real Uvicorn/HTTPX localhost reproduction: three runs per dependency set; valid input returned 200 and all five invalid-input cases returned 422. Invalid requests did not call the backend.
  • Full repository pre-commit hooks, repository-pinned Ruff 0.12.2 lint/format, targeted Pyright, compileall, and git diff whitespace checks passed.

Scope

CPU-only validation on macOS arm64. The hardware backend is stubbed, following the existing API test seam; the real application, metadata validators and HTTP transport execute. No GPU, RDMA, actual weight transfer or multi-node validation is claimed.

Kept as Draft pending my final review of the code.

Fixes MoonshotAI#110. Keep malformed dtype and shape values in Pydantic validation while preserving backend error responses. Add CPU-only API regressions for field locations and backend failures.

@koriyoshi2041 koriyoshi2041 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated exact head b855f6f9 on macOS arm64 with Python 3.13, FastAPI 0.159.1, Pydantic 2.14.1, and PyTorch 2.14.1. All 18 API tests pass. The malformed dtype/shape cases return 422 at the expected field location, load_metas is not called, and the backend RuntimeError/TypeError/ValueError controls still return 500. The conversion is confined to the two Pydantic validators; I did not find a broader exception-masking path in the diff.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed dtype/shape metadata returns HTTP 500 instead of validation errors

2 participants