[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with the OpenAPI.from_dict and MockRequest reproduction, then trace iter_request_errors through query-parameter enum validation. Add a regression test covering status= when the enum includes an empty string, and confirm the request is accepted without a ParameterValidationError.
Written by the indexing model from the issue text.
Description
Actual Behavior
Run the following code:
from openapi_core import OpenAPI
from openapi_core.testing import MockRequest
SPEC = {
"openapi": "3.2.0",
"info": {"title": "Sample", "version": "1.0.0"},
"paths": {
"/api": {
"get": {
"tags": ["Sample"],
"parameters": [
{
"name": "status",
"in": "query",
"schema": {"enum": ["Active", "Inactive", "Pending", ""]},
}
]
}
}
},
"tags": [{"name": "Sample"}],
}
openapi = OpenAPI.from_dict(SPEC)
# Empty query parameter: status=
request = MockRequest(
host_url="http://localhost",
method="get",
path="/api",
args={"status": ""},
)
if hasattr(openapi, "iter_request_errors"):
errors = list(openapi.iter_request_errors(request))
if errors:
print("INVALID")
for e in errors:
print(f" {type(e).__name__}: {e}")
else:
print("VALID")
else:
try:
openapi.validate_request(request)
print("VALID")
except Exception as exc:
print("INVALID")
print(f" {type(exc).__name__}: {exc}")
It prints:
INVALID
ParameterValidationError: Query parameter error: status
Expected Behavior
It should print VALID.
OpenAPI Core Version
0.23.1
See https://github.com/OAI/OpenAPI-Specification/discussions/5411
- Dominant language
- Python
- Stars
- 368
- Forks
- 140
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-openapi/openapi-core
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python-openapi/openapi-core#1188 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1225 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
python-openapi/openapi-core#1212 ·
-
kind/bug kind/bug/confirmed
Difficulty 3/5 1-2 days Newbie friendliness 58/100
python-openapi/openapi-core#1180 · 3 comments ·
-
kind/enhancement
Difficulty 5/5 Over a week Newbie friendliness 32/100
python-openapi/openapi-core#1142 ·
All issues in python-openapi/openapi-core
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100