[TT-12339] Rename OAS enforceTimeout field timeout to duration#8278
Conversation
The sub-second enforced-timeout field added for TT-12339 was serialized as
`timeout`. Rename it to `duration` to match the intended API contract:
x-tyk-api-gateway:
middleware:
operations:
<operationId>:
enforceTimeout:
enabled: true
duration: 100ms
Changes:
- apidef/oas/middleware.go: rename EnforceTimeout.Timeout -> Duration and its
json/bson tags `timeout` -> `duration`; update the Value deprecation note
and the Fill/ExtractTo mappings.
- apidef/oas/schema/x-tyk-api-gateway.json and .strict.json: rename the
X-Tyk-EnforceTimeout `timeout` property to `duration`.
- Update references in middleware_test.go, linter_test.go and operation_test.go.
|
This pull request renames the Files Changed AnalysisThe changes are a consistent rename operation across 5 files within the
Architecture & Impact Assessment
Data Transformation Flowgraph TD
subgraph "OAS API Definition (User Input)"
A["x-tyk-api-gateway:<br/> enforceTimeout:<br/> duration: 100ms"]
end
subgraph "Tyk Gateway (Go Code)"
B["struct EnforceTimeout {<br/> Duration tyktime.ReadableDuration json:"duration"<br/>}"r/>}"]
end
subgraph "Tyk Classic API Definition (Internal)"
C["apidef.HardTimeoutMeta {<br/> TimeoutDuration: 100ms<br/>}"]
end
A --|JSON Unmarshal|--> B
B --|ExtractTo|--> C
Scope Discovery & Context ExpansionThe scope of this change is well-contained within the Metadata
Powered by Visor from Probelabs Last updated: 2026-06-10T04:11:01.735Z | Triggered by: pr_updated | Commit: 1aebfa8 💡 TIP: You can chat with Visor using |
\n\n
Architecture Issues (1)
✅ Performance Check PassedNo performance issues found – changes LGTM. ✅ Quality Check PassedNo quality issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2026-06-10T04:10:49.317Z | Triggered by: pr_updated | Commit: 1aebfa8 💡 TIP: You can chat with Visor using |
vladzabolotnyi
left a comment
There was a problem hiding this comment.
It looks like the TT-12339 is included to 5.14.0 so we don't have any backward compat problems. Well done 💪
🎯 Recommended Merge TargetsBased on JIRA ticket TT-12339: [BE] Implement sub-second timeout for the Enforced Timeout middleware Fix Version: Tyk 5.14.0
Required:
📋 Workflow
|
|
LGTM. @jay-deshmukh can you please fix the CI and then proceed with merging this PR? |
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|
## Summary Renames the granular enforced-timeout field on the **Tyk Classic** API definition from `timeout_duration` to `duration`, so it matches the Tyk OAS field name (`enforceTimeout.duration`). Closes the Classic half of the `duration` rename agreed during TT-12339 (OAS was done in #8278). Ticket: **TT-17515** (parent TT-12339). ## What changed Minimal **wire-tag rename only** — the Go field name `HardTimeoutMeta.TimeoutDuration` is unchanged, so the enforcement path (`gateway/reverse_proxy.go`) and the negative-value validator (`apidef/validator.go`) are untouched. - `apidef/api_definitions.go` — `HardTimeoutMeta.TimeoutDuration` json/bson tag `timeout_duration` → `duration` - `apidef/schema.json` — `hard_timeouts[]` item property renamed (format pattern preserved) - `apidef/oas/middleware.go` — doc-comment reference updated - `apidef/api_definitions_test.go` — new `TestHardTimeoutMeta_DurationWireTag` (marshal/unmarshal/omitempty) ## Out of scope (by product decision) - **No round-up for Classic.** Setting only `duration` is *not* folded into the legacy whole-second `timeout` field. This was a deliberate omission (agreed with product) — a Classic API created with only `duration` has no enforced timeout on an older Gateway unless `timeout` is also set. This is an accepted, documented limitation; users wanting sub-second precision are steered to Tyk OAS. - **No new backend validation.** Negatives still rejected (existing behaviour); empty/`0`/`0ms` remain valid (no timeout). ## Compatibility - **Backwards compatible:** the legacy whole-second `timeout` field is untouched; existing APIs keep working on upgrade and downgrade. - **No JSON alias for the old key.** The pre-release `timeout_duration` name was **never released**, so there is nothing to migrate — any definition still carrying that key would deserialize the granular value as zero. This rename is safe on that premise. ## Testing - `go test ./apidef/ -run 'TestSchema$|HardTimeoutMeta_DurationWireTag' -count=1` ✅ (incl. struct-vs-embedded-schema validation) - `go test ./gateway/ -run TestTimeoutPrioritization -count=1` ✅ (sub-second + legacy enforcement) ## Downstream Dashboard support is in tyk-analytics-ui (Classic designer note) + a `tyk` dependency bump in tyk-analytics that lands after this merges.



The sub-second enforced-timeout field added for TT-12339 was serialized as
timeout. Rename it todurationto match the intended API contract:Changes:
timeout->duration; update the Value deprecation note and the Fill/ExtractTo mappings.timeoutproperty toduration.Ticket Details
TT-12339
Generated at: 2026-06-05 10:07:56