Files
coder/coderd
Michael Suchacz 36bccbf08b fix(coderd): reject overflowing workspace TTL values (#31329)
Workspace create and TTL update pass the requested `ttl_ms` to
`validWorkspaceTTLMillis`, which multiplied it by `time.Millisecond`
before it checked the bounds. Values outside the `int64` nanosecond
range wrapped around: `18446744133710` ms and `-18446744013709` ms both
became about one minute, so the API accepted them and stored a
one-minute TTL instead of returning a validation error.

The helper now rejects negative values with the minimum error and values
above 30 days with the maximum error before it converts to a
`time.Duration`. The maximum check compares whole minutes to match the
existing round down to the minute, so inputs that do not overflow keep
their current result.

Two new `TestWorkspaceUpdateTTL` rows send these values. Without the fix
both fail with `An error is expected but got nil.` (the endpoint returns
204); with the fix both get the expected validation error.

Related to #31036, which fixes the same overflow in the chat workspace
TTL setting.

> Xum, an AI agent, opened this PR for @ibetitsmike.
2026-10-27 20:48:30 +00:00
..