Skip to content

[Bug]: make test_openai_schema.py pass, enable it in CI #18162

@davidxia

Description

@davidxia

This is a follow up to PR #17664 and issues like #17037 and #17038.

As of the time of this writing, the only sub-test in tests/entrypoints/openai/test_openai_schema.py that consistently fails is POST /tokenize caused by

raise NotImplementedError(f"Unknown part type: {part_type}")
when part_type is "file". The expected response is 200 as documented by the OpenAPI spec.

How should we make this test pass? This is a requirement to eventually enabling the test in CI by removing --ignore=entrypoints/openai/test_openai_schema.py in test-pipeline.yaml.

============================================================================================ FAILURES =============================================================================================
_____________________________________________________________________ test_openapi_stateless (verbose_name='POST /tokenize') ______________________________________________________________________

    @wraps(test)
>   def test_function(*args: Any, **kwargs: Any) -> Any:

.venv/lib/python3.12/site-packages/schemathesis/_hypothesis.py:83: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

case = Case(body={'messages': [{'content': [{'file': {}, 'type': 'file'}], 'role': 'user'}]})

    @schema.parametrize(tag="debug")
    @schema.override(headers={"Content-Type": "application/json"})
    def test_openapi_stateless(case: schemathesis.Case):
        key = (
            case.operation.method.upper(),
            case.operation.path,
        )
        timeout = {
            ("POST", "/v1/chat/completions"): 99999,
        }.get(key, 10)
    
        #No need to verify SSL certificate for localhost
>       case.call_and_validate(verify=False, timeout=timeout)
E       schemathesis.exceptions.CheckFailed: 
E       
E       1. Server error
E       
E       [500] Internal Server Error:
E       
E           `{"object":"error","message":"Unknown part type: file","type":"Internal Server Error","param":null,"code":500}`
E       
E       Reproduce with: 
E       
E           curl -X POST -H 'Content-Type: application/json' -d '{"messages": [{"content": [{"file": {}, "type": "file"}], "role": "user"}]}' --insecure http://localhost:48767/tokenize
E       
E       Falsifying example: test_openapi_stateless(
E           case=,
E       )

tests/entrypoints/openai/test_openai_schema.py:57: CheckFailed
$ curl -X POST -H 'Content-Type: application/json' -d '{"messages": [{"content": [{"file": {}, "type": "file"}], "role": "user"}]}' --insecure http://localhost:8000/tokenize -v
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host localhost:8000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8000...
* connect to ::1 port 8000 from ::1 port 40420 failed: Connection refused
*   Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000
> POST /tokenize HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 75
> 
< HTTP/1.1 500 Internal Server Error
< date: Mon, 12 May 2025 17:32:11 GMT
< server: uvicorn
< content-length: 109
< content-type: application/json
< 
* Connection #0 to host localhost left intact
{"object":"error","message":"Unknown part type: file","type":"Internal Server Error","param":null,"code":500}

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions