Skip to content

Instantly share code, notes, and snippets.

@pregress
Last active July 30, 2025 08:54
Show Gist options
  • Save pregress/a9cf00fe3e75f7db579d8b8c951b77b1 to your computer and use it in GitHub Desktop.
Save pregress/a9cf00fe3e75f7db579d8b8c951b77b1 to your computer and use it in GitHub Desktop.
Repro schemathesis
Runtime Error
'NoneType' object has no attribute 'case'
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/schemathesis/engine/phases/stateful/_executor.py", line 248, in execute_state_machine_loop
InstrumentedStateMachine.run(settings=hypothesis_settings)
File "/usr/local/lib/python3.12/site-packages/schemathesis/generation/stateful/state_machine.py", line 206, in run
return run_state_machine_as_test(cls, settings=settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/schemathesis/generation/stateful/__init__.py", line 37, in run_state_machine_as_test
return _run_state_machine_as_test(state_machine_factory, settings=settings, _min_steps=2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hypothesis/stateful.py", line 257, in run_state_machine_as_test
state_machine_test(state_machine_factory)
File "/usr/local/lib/python3.12/site-packages/hypothesis/stateful.py", line 114, in run_state_machine
@given(st.data())
^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hypothesis/core.py", line 2083, in wrapped_test
raise the_error_hypothesis_found
File "/usr/local/lib/python3.12/site-packages/schemathesis/generation/stateful/state_machine.py", line 191, in _add_results_to_targets
target = self._get_target_for_result(result)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/schemathesis/specs/openapi/stateful/__init__.py", line 41, in _get_target_for_result
matcher = self._response_matchers.get(result.case.operation.label)
^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'case'
openapi: 3.1.0
info:
title: Customers.API
version: '1.0.1'
paths:
/Customers/{id}:
get:
tags:
- Customers
operationId: GetCustomerById
parameters:
- name: id
in: path
required: true
schema:
type: integer
minimum: 1
maximum: 2147483647
format: int32
description: Customer ID
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/CustomerDetail'
text/json:
schema:
$ref: '#/components/schemas/CustomerDetail'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/plain:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not Found
'415':
description: Unsupported Media Type
/Customers:
post:
tags:
- Customers
operationId: CreateCustomer
requestBody:
description: Customer
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CustomerCreate'
text/json:
schema:
$ref: '#/components/schemas/CustomerCreate'
responses:
'200':
description: Ok
content:
application/json:
schema:
type: integer
format: int32
text/plain:
schema:
type: integer
format: int32
text/json:
schema:
type: integer
format: int32
'201':
description: Created
content:
application/json:
schema:
type: integer
format: int32
text/plain:
schema:
type: integer
format: int32
text/json:
schema:
type: integer
format: int32
links:
getCustomer:
$ref: '#/components/links/getCustomer'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/plain:
schema:
$ref: '#/components/schemas/ErrorResponse'
'415':
description: Unsupported Media Type
components:
links:
getCustomer:
operationId: GetCustomerById
parameters:
id: $response.body
description: The id can be used to get a customer
schemas:
CustomerDetail:
type: object
properties:
id:
type: integer
format: int32
readOnly: true
examples:
- 1
email:
type: string
nullable: false
maxLength: 256
format: "email"
examples:
- "[email protected]"
additionalProperties: false
CustomerCreate:
type: object
required:
- email
properties:
email:
type: string
nullable: false
minLength: 1
maxLength: 256
pattern: ^(?=.*\S).+$
format: "email"
examples:
- "[email protected]"
additionalProperties: false
ErrorResponse:
type: object
properties:
Error:
type: object
additionalProperties:
type: array
items:
type: string
ValidationProblemJson:
type: object
additionalProperties: true
description: https://www.rfc-editor.org/rfc/rfc9457
properties:
title:
type: string
examples:
- what went wrong
detail:
type: string
examples:
- ModelState
status:
type: number
examples:
- 400
type:
type: string
examples:
- what went wrong
instance:
type: string
examples:
- what went wrong
code:
type: string
examples:
- ModelStateInvalid
errors:
type: object
additionalProperties:
type: array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment