Skip to content

GamesApi ValidationError on TeamRecords.year: /records returns year as a string #22

Description

@nboley2

Description

GamesApi.get_records() fails to deserialize for both years I tried (2025 and 2026). The upstream /records endpoint returns HTTP 200 with a well-formed payload, but serializes year as a JSON string ("year": "2026"), while TeamRecords.year is declared StrictInt, so pydantic rejects the response and the entire call is lost.

The strict type looks correct to me: the deployed spec at https://api.collegefootballdata.com/api-docs.json (v5.24.2) declares TeamRecords.year as {"type": "integer", "format": "int32"} and required, so the generated model faithfully matches the contract. It's the API response that disagrees with it. Flagging it here rather than on cfb-api-v2 since #21 was the same shape of problem (server value outside the spec's declared type) and got resolved on this side.

Expected Behavior

get_records(year=...) returns the parsed records, as documented.

Actual Behavior

ValidationError: 1 validation error for TeamRecords
year
  value is not a valid integer (type=type_error.integer)

Because this happens during response deserialization, nothing comes back at all.

Steps to Reproduce

import cfbd, json, requests

api = cfbd.GamesApi(cfbd.ApiClient(cfbd.Configuration(access_token="<KEY>")))

# Raw HTTP: works, and shows the offending type
raw = requests.get(
    "https://api.collegefootballdata.com/records",
    params={"year": 2026},
    headers={"Authorization": "Bearer <KEY>"},
).json()
print(json.dumps(raw[0])[:120])
# {"year": "2026", "teamId": 2, "team": "Auburn", "classification": "fbs", ...}
print(type(raw[0]["year"]))   # <class 'str'>

api.get_records(year=2026)    # raises ValidationError

Scope

  • 684/684 records for 2026, 681/681 for 2025.
  • In the same payload, teamId, expectedWins, and the nested total.wins/losses are all correctly typed integers. Other endpoints are fine too: /games returns season, week, id as integers, and /rankings returns season, week as integers.
  • Reproduced on both cfbd 5.23.0 and 5.24.2 (pydantic 1.10.26); TeamRecords.year is declared year: StrictInt = Field(...) in both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions