Overview
Following an upgrade of Tyk Gateway from version 5.8.x to 5.9.0 or later, certain OpenAPI (OAS) API specifications may fail to load during startup or synchronization. Tyk Gateway skips loading the affected API definition and outputs an error indicating that a parameter schema regular expression failed to parse due to a missing argument to a repetition operator.
Symptoms
During Gateway startup or reload, the Gateway logs an error similar to the following and omits the API from routing:
Skipping loading spec because it failed validation: invalid paths: invalid path /{param}: parameter "param" schema is invalid: error parsing regexp: missing argument to repetition operator: `*`Root Cause
This issue occurs due to two contributing factors:
- Stricter Path-Level Parameter Validation: In Tyk Gateway versions prior to 5.9.0 (which used upstream
kin-openapiv0.91.0), specification validation evaluated operation-level parameters but omitted validation of path-level parameters declared underpaths./{path}.parameters. Starting in Tyk Gateway 5.9.0, the OpenAPI parsing engine was upgraded tokin-openapiv0.132.0, which enforces comprehensive validation of path-level parameters against the OpenAPI standard during specification synchronization. - Invalid Regular Expression Syntax: Tyk Gateway validates schema regex patterns using Go's standard
regexpengine (RE2). In regular expressions, the asterisk (*) is a repetition quantifier meaning zero or more occurrences of the preceding token. When supplied without a preceding token, it is syntactically invalid and rejected by the Go regex compiler withmissing argument to repetition operator.
Resolution Steps
Update the affected OpenAPI specification using one of the following methods:
Option 1: Remove the Pattern Constraint
In OpenAPI templated paths, a path parameter such as /{param} matches any single path segment by default. If custom regex matching is not required, remove the pattern field from the parameter schema:
paths:
/{param}:
parameters:
• in: path
name: param
required: true
schema:
type: stringOption 2: Use Valid Regular Expression Wildcard Syntax
If pattern matching is required, replace the lone asterisk with valid Go RE2 wildcard syntax, such as .* (matches zero or more characters) or .+ (matches one or more characters):
paths:
/{param}:
parameters:
• in: path
name: param
required: true
schema:
type: string
pattern: '.*'Verification
- Save and apply the updated API definition.
- Reload or restart Tyk Gateway.
- Inspect the Gateway logs to ensure the specification passes validation and loads without errors.
- Send a test request to confirm that the endpoint routes properly to the upstream target.
Applies To
- Tyk Gateway 5.9.0 and later (including 5.13.x)
- Tyk Dashboard 5.9.0 and later
- OpenAPI / OAS 3.0 API definitions using path-level parameters
Comments
0 comments
Please sign in to leave a comment.