E07730: HTTP PATH variable count and PATH parameter count mismatch
What went wrong
The number of path variables in the URI pattern doesn't match the number of PATH parameters in the operation signature.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 946 (How must path variable counts match parameters in EK9 services?)
How to fix it
- Declare one PATH parameter for each path variable in the URI
- A parameter binds the variable of the same name, or the one named by :=: PATH "name"
The [EXAMPLE] section below shows two URI variables with one parameter, and the method taking both.
Common causes
- Missing parameter for a path variable
- Extra path variable without a parameter
- Typo in a variable name
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07730: HTTP PATH variable count and PATH parameter count mismatch
#!ek9 defines module error.e07730.bad defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open //Two variables in the URI, one parameter byRoute() as GET for :/{region}/{route} -> region as String <- response as HTTPResponse: TextResponse(region)
Fixed: Declare a parameter for every URI variable
#!ek9 defines module error.e07730.good defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open byRoute() as GET for :/{region}/{route} -> region as String route as String <- response as HTTPResponse: TextResponse(`${region} ${route}`)