huma icon indicating copy to clipboard operation
huma copied to clipboard

Navigating to an endpoint with spaces in its operationID forces a redirect in Stoplight

Open BasMichielsen opened this issue 10 months ago • 4 comments

Somewhere between version v 2.23 and v 2.28 something changed regarding OperationIDs with spaces in them. I just upgraded from v 2.23 to v 2.28 and now my operations that have spaces in their operationIDs can no longer be viewed in Stoplight and force a web redirect to the root. However, when I rollback to v 2.23 it works again. Is this accidental, or should an OperationID not have a space in it? If the latter, I would have expected an error message explaining the issue. If the former, there is probably a bug.

name := "Get All Detections"
...
huma.Register(api, huma.Operation{
   OperationID: name, 
   Path: path, 
   Method: method,
   }, func(ctx context.Context, input *struct{}) (*DetectionsHolder, error) {
...
}

BasMichielsen avatar Feb 09 '25 12:02 BasMichielsen

This is likely due to https://github.com/danielgtaylor/huma/pull/689. Might be worth creating a ticket for https://github.com/stoplightio/elements.

As a workaround, you can provide your own docs route with the old behavior and set the docs path to "".

danielgtaylor avatar Feb 10 '25 22:02 danielgtaylor

Thanks for your response, and of course I realize that this may be an issue in Stoplight and thus something huma has little influence over. Nevertheless, as a user of huma it does affect me in an "uncomfortable" way. I updated huma and something that worked before, suddenly and silently does no longer work. If there is a way to make it less silent, i.e. "warning your operationID has spaces in it and version X of Stoplight that you are using seems to have poor support for this." it would make huma a more robust product for its end-users. Thanks for the workaround, I may consider that. Until then, can you say which version of huma is the highest version that is likely unaffected by this issue?

BasMichielsen avatar Feb 11 '25 08:02 BasMichielsen

@BasMichielsen good points. You should be fine with v2.27.0.

danielgtaylor avatar Feb 11 '25 17:02 danielgtaylor

I just noticed this issue. I use spaces in my OperationIDs. I had not noticed until now since I use Bruno to test api's. But I was testing Stoplight and noticed this problem.

I can confirm the issue happened from v2.27.0 to v2.28.0

migueldv90 avatar Feb 11 '25 22:02 migueldv90