[BUG] curl code samples omit non-printable characters #2159
Labels
Status: Needs Triage
Requires initial assessment to categorize and prioritize
Type: Bug
Errors or unexpected behavior
Checklist
Describe the bug
I had a FastAPI endpoint which accidentally leaked the header definition for
X-Forwarded-For
into the OpenAPI docs and that caused a Schemathesis run to fail, emitting a curl sample like this:curl -X GET -H 'x-forwarded-for: 0' http://localhost:8000/search/latest-magazines
That worked without error when I tried to reproduce, but I knew it was failing based on my service's logs. I added
--code-sample-style=python
and the cause became clear:To Reproduce
Please include a minimal API schema causing this issue:
Expected behavior
Ideally the curl examples would either include the escaped values — but this introduces shell-specific behaviour since you'd need to use something like
curl -H "X-Forwarded-For: $(printf '\01f')" …
so it might be effective to simply alert the user with a text message that the curl sample is incomplete. In my case, the fact that it printed without a warning and with what appears to be a complete string was somewhat confusingEnvironment
The text was updated successfully, but these errors were encountered: