Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of empty optional UUID array header #1233

Closed
mxk opened this issue May 3, 2024 · 0 comments · Fixed by #1245
Closed

Incorrect handling of empty optional UUID array header #1233

mxk opened this issue May 3, 2024 · 0 comments · Fixed by #1245
Labels
bug Something isn't working

Comments

@mxk
Copy link

mxk commented May 3, 2024

What version of ogen are you using?

github.com/ogen-go/ogen v1.0.1-0.20240415140940-8c1c10db7ff2

Can this issue be reproduced with the latest version?

Yes

What did you do?

I generated client and server code from the following UUID header parameter:

"parameters": [
	{
		"name": "My-Array",
		"in": "header",
		"required": false,
		"schema": {
			"type": "array",
			"items": {
				"type": "string",
				"format": "uuid"
			}
		}
	}
]

What did you expect to see?

Invoking the API from the client using httptest server should work when this parameter is not specified in the request.

What did you see instead?

First, the client sends an empty string header for this parameter when it would be more efficient to omit the header since it's optional.

Second, the DecodeArray function on the server splits the string on commas, and then tries to decode the UUID using conv.ToUUID, which fails with invalid UUID length: 0 error.

There needs to be an explicit check on the server for an empty array, but the client should also avoid sending this header when it doesn't have a value.

@mxk mxk added the bug Something isn't working label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant