You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose you have an API with ONLY the following URI implemented: /api/v1/index.cfm/pizza/{topping}
If a request arrives for /api/v1/index.cfm/pizza we currently return a 404. This is good. 👍🏻
If a request arrives for /api/v1/index.cfm/pizza/ we currently throw an exception. This is bad. 👎🏻
The problem is that an empty-string is an acceptable match for tokens. This behavior should continue. There are valid reasons to expect and allow empty-string as a token value.
However, in this case, when buildRequestArguments executes, it doesn't account for this possibility. We would expect a response in the shape of { topping: "" }. Instead an error is thrown while trying to reference the token here (line 1015).
In this modification, I added a line to create local.tokenValue, which checks whether local.t is within the bounds of local.tokenValues before attempting to access it. If local.t is greater than the number of tokens, it sets local.tokenValue to an empty string.
This change should help prevent errors when an empty string is encountered, ensuring that an API can handle such cases gracefully.
Suppose you have an API with ONLY the following URI implemented:
/api/v1/index.cfm/pizza/{topping}
/api/v1/index.cfm/pizza
we currently return a 404. This is good. 👍🏻/api/v1/index.cfm/pizza/
we currently throw an exception. This is bad. 👎🏻The problem is that an empty-string is an acceptable match for tokens. This behavior should continue. There are valid reasons to expect and allow empty-string as a token value.
However, in this case, when
buildRequestArguments
executes, it doesn't account for this possibility. We would expect a response in the shape of{ topping: "" }
. Instead an error is thrown while trying to reference the token here (line 1015).Taffy/core/api.cfc
Lines 1009 to 1017 in ce987af
The text was updated successfully, but these errors were encountered: