TT-15813: add api-level timeout configuration#8282
Conversation
|
This PR introduces an API-level timeout configuration, creating a new layer of control between the global gateway-level default and specific endpoint-level timeouts. This feature allows developers to set a uniform timeout for all endpoints within an API definition, simplifying configuration and reducing redundancy. The new timeout precedence is: Endpoint-level → API-level → Gateway default. Files Changed AnalysisThe changes are primarily located in the
Architecture & Impact Assessment
Timeout Resolution FlowThe diagram below illustrates how the gateway determines which timeout to apply to an incoming request. graph TD
A[Incoming Request] --> B{Check for Endpoint-Level Timeout};
B --|Yes|--> C[Use Endpoint Timeout];
B --|No|--> D{Check for API-Level Timeout};
D --|"Yes (Enabled)"|--> E[Use API-Level Timeout];
D --|"No / Disabled"|--> F[Use Gateway Default Timeout];
C --> G[Apply Timeout and Proxy Request];
E --> G;
F --> G;
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2026-06-15T11:48:22.488Z | Triggered by: pr_updated | Commit: ed26897 💡 TIP: You can chat with Visor using |
Security Issues (1)
Security Issues (1)
No architecture issues found – changes LGTM. ✅ Performance Check PassedNo performance issues found – changes LGTM. Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2026-06-15T11:47:43.537Z | Triggered by: pr_updated | Commit: ed26897 💡 TIP: You can chat with Visor using |
…and endpoints with new docstring
…ave backward compat problem and ReadableDuration supports string
|
/visor
This is intended behavior that described on the latest comments on the ticket |
🎯 Recommended Merge TargetsBased on JIRA ticket TT-15813: [BE] Feature Request: API-Level Timeout Configuration Fix Version: Tyk 5.14.0
Required:
📋 Workflow
|
|
SentinelOne CNS Hardcoded Secret Detector SentinelOne CNS is a cloud-agnostic, agentless CSPM & CWPP solution that continuously detects and prevents vulnerabilities that have the highest probability of being exploited in Azure, AWS, Google Cloud, and Kubernetes. |
🚨 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. |
|



Description
Ticket: https://tyktech.atlassian.net/browse/TT-15813
Introduces API-level timeout configuration (
global_enforce_timeout) as a middle layer between the gateway-level default and endpoint-level enforced timeouts.Priority order: endpoint-level → API-level → gateway default
Related Issue
https://tyktech.atlassian.net/browse/TT-15813
Motivation and Context
Previously, users could only configure timeouts globally (affecting all APIs) or per-endpoint (tedious and error-prone). This change adds a middle layer so a single timeout value can be applied across all endpoints of a given API, while still allowing individual endpoints to override it.
How This Has Been Tested
Unit tests:
TestRuleValidateGlobalEnforceTimeout_Validate— validator rejects negative durationsTestUpstream/enforce_timeout— OASFill/ExtractToround-trips for enabled, disabled, sub-second, and zero casesTestUpstreamEnforceTimeoutSchema— OAS JSON schema rejects missingenabled, bad duration format, and non-string durationTestSchema_GlobalEnforceTimeout— classic apidefschema.jsonaccepts valid string durationsTestSetDisabledFlags—SetDisabledFlagscorrectly setsGlobalEnforceTimeoutDisabled=truewhen no timeout is configuredTestXTykGateway_Lint— strict schema validation passes with the new field populatedIntegration tests:
TestAPILevelTimeout— covers: timeout triggers on slow upstream, no trigger on fast upstream, API-level overrides gateway default, endpoint-level overrides API-level, API-level applies across all endpoints without an override, disabled API-level falls back to gateway defaultTypes of changes
Checklist
Implementation Notes (for reviewer)
New apidef fields (on
VersionInfo, insideversion_data.versions.<version_name>):global_enforce_timeout tyktime.ReadableDuration— human-readable duration (e.g."500ms","5s","2m")global_enforce_timeout_disabled bool— allows OAS to round-tripenabled: falsewith a non-zero duration without losing the valueOAS contract:
Classic apidef contract
{ "version_data": { "versions": { "Default": { "global_enforce_timeout": "5s", "global_enforce_timeout_disabled": false } } } }Demo
Each version on Classic API has its unique api-level timeout
classic-api-versions-timeout.mov
Api level timeout with OAS
api-level-timeout-oas.mov
Mongo doc new fields representation
Ticket Details
TT-15813
Generated at: 2026-06-05 07:48:23
Ticket Details
TT-15813
Generated at: 2026-06-05 07:56:06