api: autoPause default is declared in the spec and in a Go constant with no test keeping them in sync

未关闭 适合新手
#3,765 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@AdaAibaby 已经在做这个了。

开始于 2026年10月29日。

  • #3767 来自 @AdaAibaby —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, openapi

调研方向

从 packages/api/internal/api/spec_test.go 和 issue 中提到的现有契约测试开始。阅读 spec/openapi.yml 中的 NewSandbox 和 NewSandboxV2 schemas,然后定位 sandboxtypes.AutoPauseDefault 及其在 sandbox_create.go 中的用法。当任一 spec 默认值与 Go 常量不同时测试失败,而二者匹配时测试通过,即为完成。

由索引模型根据 Issue 内容生成。

描述

Summary

The default timeout action for a sandbox (autoPause when omitted) is declared in two places in this repo with no test keeping them in sync:

  1. OpenAPI spec — spec/openapi.yml, NewSandbox and NewSandboxV2 both declare autoPause: { type: boolean, default: false }. This is documentation only: the generated Go type is *bool with omitempty (api.gen.go), so the spec default is never applied at decode time.
  2. Go constant — sandboxtypes.AutoPauseDefault = false, which is what sandbox_create.go actually applies via DerefOrDefault(body.AutoPause, sandbox.AutoPauseDefault) when the request omits autoPause.

The spec value is the one the SDKs read and document as the default (see e2b-dev/E2B #2057 — both SDKs hardcode "currently kill" against this). If the Go constant ever changes without the spec (or vice versa), the published contract silently lies about what an omitted autoPause does, and the SDKs' documented/validated default drifts from reality — with no signal.

Proposal

Add a contract test (mirroring the existing TestSpecSecuritySchemeHeaderNames / TestTemplateBuildMinimumFreeDiskContract pattern in packages/api/internal/api/spec_test.go) that asserts the spec's declared autoPause default on NewSandbox and NewSandboxV2 equals sandboxtypes.AutoPauseDefault. Makes the spec the single documented source of the default and fails CI on drift.

This is the infra-side half of the drift concern raised in e2b-dev/E2B #2057 (the SDK-side half — single-sourcing the SDK's local assumption — is handled there).

主要语言
Go
星标
1.8k
派生
503
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

e2b-dev/runtime 的其他 Issue

查看 e2b-dev/runtime 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。