Skip to content

Conversation

@calumbell
Copy link
Contributor

Closes #621

This PR addresses a bug on the /v2/items endpoint where the weapon and armor fields where returning inconsistant results when different depth query parameters were passed with API requests. These fields might have returned null at depth=0, but instead returned a large object with mostly empty keys.

Follow this bugfix, null "weapon" and "armor" fields now remain null at all depths.

/v2/items/srd_alchemists-fire-flask/?fields=name,weapon,armor&depth=1

{
    "weapon": null,
    "armor": null,
    "name": "Alchemist's Fire (Flask)"
}

Items with a defined "armor" or "weapon" work as they did before:

/v2/items/srd_longsword/?fields=name,weapon,armor&depth=1

{
    "weapon": {
        "key": "srd_longsword",
        "is_versatile": true,
         ...
    },
    "armor": null,
    "name": "Longsword"
}

/v2/items/srd_chain-mail/?fields=name,weapon,armor&depth=1

{
    "weapon": null,
    "armor": {
        "key": "srd_chain-mail",
        "ac_display": "16",
        "category": "heavy",
        ...
    },
    "name": "Chain mail"
}

@calumbell calumbell merged commit ce558ce into open5e:staging Mar 2, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: v2/items endpoint has weird interaction between null FKs and depth parameter

2 participants