Repository navigation
Conversation
…fault The default timeout action (autoPause when omitted) is declared twice with no guard: in spec/openapi.yml (NewSandbox/NewSandboxV2 autoPause: default: false, documentation only — the generated field is *bool omitempty) and in the Go constant sandboxtypes.AutoPauseDefault that sandbox_create actually applies. The SDKs read and document the spec value as the default (e2b-dev/E2B e2b-dev#2057), so a drift between the two silently makes the published contract lie about what an omitted autoPause does. Add a contract test asserting the spec's autoPause default on both create schemas equals sandboxtypes.AutoPauseDefault, mirroring the existing spec_test.go contract tests. External test package (api_test) because sandboxtypes imports the api package. Fixes e2b-dev#3765
This branch has not been deployed
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.
Problem
Fixes #3765.
The sandbox default timeout action (
autoPausewhen omitted) is declared in two places in this repo with no test keeping them in sync:spec/openapi.yml, bothNewSandboxandNewSandboxV2declareautoPause: { type: boolean, default: false }. Documentation only: the generated Go type is*bool+omitempty(api.gen.go), so the spec default is never applied at decode time.sandboxtypes.AutoPauseDefault = false, whichsandbox_create.goactually applies viaDerefOrDefault(body.AutoPause, sandbox.AutoPauseDefault)when the request omitsautoPause.The SDKs read and document the spec value as the default (e2b-dev/E2B #2057 — both SDKs hardcode currently kill against it). A drift between the spec and the constant would silently make the published contract lie about what an omitted
autoPausedoes, with no signal.Change
Add a contract test (mirroring the existing
TestSpecSecuritySchemeHeaderNames/TestTemplateBuildMinimumFreeDiskContractpattern inspec_test.go) asserting the spec'sautoPausedefault onNewSandboxandNewSandboxV2equalssandboxtypes.AutoPauseDefault. Fails CI on drift, making the spec the single documented source of the default.Test-only; no behavior change. External test package (
api_test) becausesandboxtypesimports theapipackage (an in-package test would be an import cycle).This is the infra-side half of the drift concern in e2b-dev/E2B #2057; the SDK-side half (single-sourcing the SDK's local assumption) is handled in e2b-dev/E2B#2058.
Test
go test ./internal/api/ -run TestSpecAutoPauseDefaultMatchesConstantpasses (both subtests);go vetandgolangci-lintclean on the file.