Skip to content

Bug: Incorrect schema for SimpleClassroomAssignment #144

@amitkparekh

Description

@amitkparekh

Hi! Thank you so much for maintaining this repo! I'm using it to make managing GitHub Classroom assignments much simpler.

I found something odd. I got this error when trying to call github.rest.classroom.list_assignments_for_a_classroom. It is expected to return list[SimpleClassroomAssignment] but the validation fails with the following traceback:

Traceback (most recent call last):
  File "/Users/amit/Develop/f21dl-align-students/.venv/lib/python3.12/site-packages/githubkit/response.py", line 63, in parsed_data
    return type_validate_json(self._data_model, self.content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amit/Develop/f21dl-align-students/.venv/lib/python3.12/site-packages/githubkit/compat.py", line 51, in type_validate_json
    return TypeAdapter(type_).validate_json(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amit/Develop/f21dl-align-students/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 135, in wrapped
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amit/Develop/f21dl-align-students/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 384, in validate_json
    return self.validator.validate_json(data, strict=strict, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 3 validation errors for list[SimpleClassroomAssignment]
0.editor
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type
0.submitted
  Field required [type=missing, input_value={'id': 662312, 'public_re...80196408-dmml-2024-25'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
0.language
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type

This is what the JSON output looks like from the API (with possibly sensitive details obfuscated):

CleanShot 2024-10-03 at 09 22 31

As you can see from the raw response, editor, submitted and language are all None and not str. It appears that the schema in the documentation is not the same as what is getting returned.

I thought about submitting a PR but then I wasn't sure how you would want to handle this? For now, I'm having to just use the JSON instead of the Pydantic outputs so not urgent but something to be aware of?

Again, thanks for making this library! It's made my life much easier!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Rest APIbugSomething isn't workingschemaschema related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions