Repository navigation
feat(plane-types): one plane_500() for the pin's three 500 texts - #126
Merged
Merged
Conversation
Round 27 decided to reproduce every Plane 500 as a handled response, and the text of a 500 is part of the contract (research/0007 PQ-409). They are now answered by one function in a new crate, thrust-plane-types: plane_500(kind, cause) sets status 500, writes the pin's exact body for that kind and attaches the cause as InternalErrorDetail, so the root logs it and the body never carries it. Plane500 names the three texts: the base handlers' catch-all, project create's, and the generic asset GET's. /api/v1 answers its 500s through it. V1Error::Plane500 now carries a kind and a required cause, built by V1Error::internal and V1Error::unexpected; the free thrust_api_v1::plane_500() is removed, so a deliberate 500 now says why in the log. The array body to project create was the one 500 written by hand; it is Plane500::UnexpectedError. The wire does not move: the v1 suites assert the same statuses and bodies and pass as before. One test is edited on purpose, a_500_keeps_its_cause_out_of_the_body, which asserted that a deliberate 500 carries no cause; the helper now always attaches one (the test is not wrong, the contract changed). Tests, in the new crate: parity_plane_500_bodies compares each kind's status and body bytes with a fixture. The base text is tied to the oracle's recording (corpus/assets.json#workspace-asset-upload), every 500 recorded in the corpus must be one of the three texts, and the other two cite the pinned source (rule 9b). Controls: one changed byte, a changed status, and one kind against another's fixture each make the comparison fail. prop_plane_500_never_leaks_the_cause generates the cause. scripts/check-plane-500.sh (CI job deps, with --self-test as its control) refuses INTERNAL_SERVER_ERROR, from_u16(500), try_from(500) and .status(500) in the src of thrust-api-v1 and thrust-compat-plane, and refuses to pass on a directory with no .rs file. Run against the previous v1 sources it reports error.rs:102 and projects.rs:377. The crate is added to CLEAN_CRATES in check-deps.sh, and docs/src/contributing crates.md is brought up to date with it (its crate counts were already stale). The internal API (thrust-compat-plane) does not call it yet; that is the next change for #51. Refs: plane-byd.5 Co-Authored-By: Claude Sonnet 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.
What
First of three changes for #51. It adds the one helper and moves
/api/v1onto it. The internal API (thrust-compat-plane) and the acceptance-list work are the next two and are not in here. No wire change.thrust-plane-types:Plane500 { SomethingWentWrong, UnexpectedError, InternalServerError }andplane_500(kind, cause) -> Response<Body>. It sets 500, writes the pin's exact body for the kind and attaches the cause asInternalErrorDetail, so the root logs it and the body never carries it./api/v1answers every 500 through it.V1Error::Plane500now holds a kind and a required cause (V1Error::internal,V1Error::unexpected). The array body to project create was the one hand-written 500; it is nowUnexpectedError. Each of the nine deliberate 500s names its rule as the cause (per_page <= 0 ... (PQ-402)and so on), which the log gains.scripts/check-plane-500.sh(CI jobdeps, with--self-test) refusesINTERNAL_SERVER_ERROR,from_u16(500),try_from(500)and.status(500)in thesrcofthrust-api-v1andthrust-compat-plane, and refuses to pass on a directory with no.rsfile.CLEAN_CRATES;crates.mdandstandards.mdname it and the guard. The crate counts incrates.mdwere already stale and are corrected.Evidence
cargo nextest run -p thrust-api-v1 -p thrust-plane-typescargo clippy --workspace --all-targets --locked -- -D warnings,cargo fmt --all --checkscripts/check-deps.shFORBIDDENscripts/check-plane-500.sh--self-test: 12 cases, each pattern refused, an empty or missing directory is exit 2. Run on the previous v1error.rsandprojects.rsit reportserror.rs:102andprojects.rs:377and exits 1.lib.rsFAILline, so a compile error cannot pass for one.cargo mutants -f crates/thrust-plane-types/src/lib.rsTests in the new crate:
parity_plane_500_bodies(status and body bytes per kind against a fixture), a check that the base text's fixture is the oracle's owncorpus/assets.json#workspace-asset-upload, a scan that every 500 recorded in the corpus (4 today) is one of the three texts, controls (a changed byte, a changed status, a kind against another kind's fixture), andprop_plane_500_never_leaks_the_cause(status, headers and body equal those for an empty cause, whatever the cause is).Read before merging
a_500_keeps_its_cause_out_of_the_bodyasserted that a deliberate 500 carries no cause. The helper now always attaches one, so the test now asserts that. The contract changed; the test was not wrong.thrust_api_v1::plane_500()is removed, not kept beside the new one, so there is oneplane_500. The crate is namedthrust-plane-types, notthrust-compat-typesas chore(contracts): keep compat DTOs out ofthrust-contracts; add thecheck-deps.shrule #52 writes it, because/api/v1uses it too; chore(contracts): keep compat DTOs out ofthrust-contracts; add thecheck-deps.shrule #52's PR should change that line.An unexpected error occurredandInternal server errorwere never reached by the harness (testing rule 9b). Each fixture says so.InternalServerErrorhas no caller yet (v1 has no asset routes).Not run here
The contract suite and the oracle gate, which this change does not touch (no route, status or body moves). CI runs them.
Next for #51
The internal API's 500 (it answers a Thrust-shaped body today, and 400 where the pin answers 500 for
per_page<= 0), then the acceptance list with thecomm -3check. Not a closing PR: it says "Refs #51" on purpose.🤖 Generated with Claude Code