Follow the tightened script request bodies in gateway 0.7.0 - #102
Draft
bburda wants to merge 1 commit into
Draft
Conversation
The gateway now describes both script request bodies instead of leaving them open. The upload body declares a required `file` part with optional `metadata`; the execution body is `ScriptExecutionRequest`, with `execution_type` required. Two casts that existed only because those bodies used to be untyped no longer compile against the generated types. The execution cast goes away entirely - StartScriptExecutionRequest already mirrors the generated shape, so the body passes through and any future divergence between the two surfaces as a type error. The upload keeps a cast, because FormData is a DOM interface and can never be assignable to a generated object type, but it now names the declared body instead of `Record<string, unknown>`, so a change to the parts is caught at compile time rather than as a 400 at runtime.
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.
Pull Request
Summary
The gateway 0.7.0 spec describes both script request bodies instead of leaving them open. The upload body declares a required
filepart with optionalmetadata; the execution body isScriptExecutionRequest, withexecution_typerequired. Two casts inapi-dispatch.tsexisted only because those bodies used to be untyped, and they stop compiling against the 0.7.0 client.The execution cast is gone.
StartScriptExecutionRequestalready has the same shape as the generatedScriptExecutionRequest, so the body passes straight through, and if the two ever drift apart it becomes a type error here.The upload keeps a cast, because FormData is a DOM interface and can never be assignable to a generated object type. It now names the declared body type instead of
Record<string, unknown>, so a change to the parts is caught at compile time rather than as a 400 at runtime.No request path changed between 0.6.0 and 0.7.0, so nothing else is affected.
This is a draft on purpose. The client pin moves to
^0.7.0, which is not published yet, sopackage-lock.jsonstill records 0.6.0 andnpm ciwill fail until the release exists. Runnpm installto refresh the lock once@selfpatch/ros2-medkit-client-ts0.7.0 is out, then this is ready.Issue
Type
Testing
Verified against a gateway built from the 0.7.0 release branch, with the client regenerated from that gateway's exported spec and installed locally.
npm run typecheckandnpm run buildare clean. Before the change they failed with four errors insrc/lib/api-dispatch.ts.npm run lintis clean.npm testpasses 682 tests in 34 files. Worth noting that it also passed before the change, because vitest does not typecheck, so the unit suite is not what catches this.npx playwright testagainst the live 0.7.0 gateway passes 16 tests, 3 skipped (the rosbag project needs its own stack). This covers the upload, run and delete path and the execution path, which are the lines the casts sit on.Checklist
npm run lint)npm run build)