Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript ErrorContainer type is incorrect #782

Closed
snikch opened this issue Oct 20, 2020 · 5 comments
Closed

Typescript ErrorContainer type is incorrect #782

snikch opened this issue Oct 20, 2020 · 5 comments
Labels
bug Something is not working. corp/m4 Up for M4 at Ory Corp.

Comments

@snikch
Copy link

snikch commented Oct 20, 2020

Describe the bug

The current typescript type for ErrorContainer in api.d.ts doesn't correctly represent the payload.

Reproducing the bug

Look at the typescript bindings to see the ErrorContainer type.

/**
 *
 * @export
 * @interface ErrorContainer
 */
export interface ErrorContainer {
    /**
     * Errors in the container
     * @type {object}
     * @memberof ErrorContainer
     */
    errors: object;
    /**
     *
     * @type {string}
     * @memberof ErrorContainer
     */
    id: string;
}

Generate an error and look at the payload.

{
  "id": "d513f09a-11df-4fb7-a258-71acafc780f0",
  "errors": [{
    "code": 403,
    "reason": "A request failed due to a missing or invalid csrf_token value.",
    "status": "Forbidden",
    "message": "The requested action was forbidden"
  }]
}

As you can see, the error key is an array not an object.

The correct type would be:

export interface ErrorContainer {
    /**
     * Errors in the container
     * @type {error}
     * @memberof ErrorContainer
     */
    errors: Error[];
    /**
     *
     * @type {string}
     * @memberof ErrorContainer
     */
    id: string;
}

export interface Error {
    /**
     *
     * @type {number}
     * @memberof Error
     */
    code: number;
    /**
     *
     * @type {string}
     * @memberof Error
     */
    reason: string;
    /**
     *
     * @type {string}
     * @memberof Error
     */
    status: string;
    /**
     *
     * @type {string}
     * @memberof Error
     */
    message: string;
}

Environment

Both server and client package are 0.5.0-alpha.1

@aeneasr
Copy link
Member

aeneasr commented Oct 21, 2020

Does this refer to the self-service error endpoint?

@aeneasr aeneasr added bug Something is not working. corp/m3 Up for M3 at Ory Corp. labels Oct 21, 2020
@snikch
Copy link
Author

snikch commented Oct 21, 2020

Correct, yes.

@aeneasr
Copy link
Member

aeneasr commented Oct 23, 2020

I looked into this a bit, the problem right now is that the error could also have a different layout, which is why this is currently polymorph. One problem are for example system errors that do not have a proper JSON object representation. So this needs to be fixed in both the server as well as the swagger spec, but it's a bit more work :)

@aeneasr aeneasr added this to the v0.7.0-alpha.1 milestone Oct 23, 2020
@snikch
Copy link
Author

snikch commented Oct 24, 2020

Ok, that makes sense. I've just created my own type as needed for the moment and cast it to it 👌

@aeneasr aeneasr added corp/m4 Up for M4 at Ory Corp. and removed corp/m3 Up for M3 at Ory Corp. labels Nov 9, 2020
@aeneasr
Copy link
Member

aeneasr commented Jul 12, 2021

Resolved on master!

@aeneasr aeneasr closed this as completed Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working. corp/m4 Up for M4 at Ory Corp.
Projects
None yet
Development

No branches or pull requests

2 participants