Skip to content

fix: token refresh error mutation breaks instanceof FgaApiAuthenticationError #328

@aaguiarz

Description

@aaguiarz

Summary

When client-credentials token refresh fails with a non-auth API error (e.g. 500), Credentials.refreshAccessToken() mutates an existing FgaApiError instance by assigning constructor, name, and auth fields.

Impact

Mutating object properties does not change the prototype chain, so instanceof FgaApiAuthenticationError fails even though the error is intended to be treated as authentication failure.

Expected

Token-refresh failures should throw a real FgaApiAuthenticationError instance with auth context.

Proposed Fix

Construct and throw a new FgaApiAuthenticationError (or equivalent wrapper) instead of mutating an existing error object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Intake

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions