chore: sync infra OpenAPI specs#285
chore: sync infra OpenAPI specs#285e2b-generated-code-auto-fixer[bot] wants to merge 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 837b7439b9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| - cpuUsedPct | ||
| - memUsed | ||
| - memTotal | ||
| - memCache |
There was a problem hiding this comment.
Keep SandboxMetric fixtures type-compatible
Adding memCache as a required field makes SandboxMetric immediately stricter for all generated TypeScript consumers, but this commit does not update existing metric fixtures (for example in src/__test__/unit/sandbox-monitoring-chart-model.test.ts), so type-checking now reports missing memCache on those objects. If the intent is a non-breaking schema sync, mark memCache optional until all producers/fixtures are updated, or include those fixture updates in the same change.
Useful? React with 👍 / 👎.
| * Format: int64 | ||
| * @description Cached memory (page cache) in bytes | ||
| */ | ||
| memCache: number | ||
| /** |
There was a problem hiding this comment.
🔴 Adding memCache: number as a required field to SandboxMetric breaks the existing unit test at src/__test__/unit/sandbox-monitoring-chart-model.test.ts. The baseMetric fixture is typed as Omit<SandboxMetric, 'timestampUnix' | 'cpuUsedPct' | 'memUsed' | 'diskUsed'>, which leaves memCache required but baseMetric only provides timestamp, cpuCount, memTotal, and diskTotal. Every SandboxMetric[] array in the test file also spreads baseMetric and adds back only the four omitted fields, never memCache, causing TypeScript compilation failures throughout the test suite. Fix by adding memCache to baseMetric and to the Omit union, or by providing memCache in every individual test object.
Extended reasoning...
What the bug is and how it manifests
This PR adds memCache: number as a required field to the SandboxMetric schema in both spec/openapi.infra.yaml and the generated src/types/infra-api.types.ts (lines 2348-2352). While that correctly reflects the updated OpenAPI spec, it inadvertently breaks the unit test file src/__test__/unit/sandbox-monitoring-chart-model.test.ts, which constructs test fixtures against the SandboxMetric type.
The specific code path that triggers it
The test file imports SandboxMetric from @/server/api/models/sandboxes.models, which re-exports InfraComponents['schemas']['SandboxMetric'] -- exactly the type modified by this PR. The test defines a shared baseMetric constant typed with a satisfies expression. Before this PR, the Omit type removed four fields (timestampUnix, cpuUsedPct, memUsed, diskUsed), leaving { timestamp, cpuCount, memTotal, diskTotal } as the required keys -- which baseMetric satisfied. After this PR, memCache is required in SandboxMetric but is NOT in the Omit list, so it remains required in the resulting type. baseMetric does not include memCache, causing a TypeScript compile error on the satisfies expression.
Why existing code does not prevent it
The Omit list was written before memCache existed. There is no mechanism to automatically synchronise the omit list with new required fields added to the schema. When memCache was appended to the required array in the OpenAPI spec (and thus the generated TypeScript), the test fixtures were not updated in tandem.
What the impact would be
Every SandboxMetric[] array in the test file spreads baseMetric and then adds back only timestampUnix, cpuUsedPct, memUsed, and diskUsed. None of the individual metric objects supply memCache, so all of them also fail type-checking as SandboxMetric. The TypeScript compiler will reject the entire test file, blocking tsc --noEmit checks and any CI step that compiles the test suite.
Step-by-step proof
- After this PR,
SandboxMetrichas required fields:timestamp,timestampUnix,cpuCount,cpuUsedPct,memUsed,memTotal,memCache,diskUsed,diskTotal. Omit<SandboxMetric, 'timestampUnix' | 'cpuUsedPct' | 'memUsed' | 'diskUsed'>yields an object with required fields:timestamp,cpuCount,memTotal,memCache,diskTotal.baseMetriconly providestimestamp,cpuCount,memTotal,diskTotal--memCacheis absent.- The
satisfiescheck fails: TypeScript reports thatmemCacheis missing inbaseMetric. - Each test array entry spreads
baseMetricand addstimestampUnix,cpuUsedPct,memUsed,diskUsed-- still lackingmemCache-- so allSandboxMetric[]typed arrays also fail.
How to fix it
Either add 'memCache' to the Omit union in the test (requiring each individual spread object to supply memCache), or add memCache: 0 to baseMetric and keep the Omit list as-is. The latter is simpler and most consistent with the existing pattern.
This PR syncs OpenAPI specs from e2b-dev/infra:
spec/openapi.infra.yamlspec/openapi.dashboard-api.yamlIt also regenerates dependent TypeScript API types and applies formatting/lint autofixes.
This PR was automatically created by the sync-infra-specs workflow.