Skip to content

Update API error format on Attester #2241

Closed

Description

@DenBond7

ref #2171 (comment)

FES

{
  "code": 401,
  "message": "Authorization credentials required",
  "details": "io.javalin.http.UnauthorizedResponse"
}

Attester

{
    "error": {
        "message": "Body should not be empty"
    }
}

PubLookup

{
  "code": 404,
  "message": "Not Found",
  "details": ""
}

EKM

{
  "code": 401,
  "message": "Authorization credentials required",
  "details": "io.javalin.http.UnauthorizedResponse: Authorization credentials required"
}

Backend

{
    "error": {
        "code": 400,
        "message": "Wrong request received",
        "internal": "Please add a json body"
    }
}

@tomholub Is it possible to have the same error format for all APIs? it will help to simplify code.

It would be nice to have
(I prefer this one)

{
    "error": {
        "_": ""
        "_": "",
        ...
    }
}

or

{
  "_": "",
  "_": ""
}

Activity

  1. added this to the Discussion milestone on Mar 13, 2023
  2. tomholub commented on Mar 13, 2023

    @tomholub
    Collaborator

    Backend will be removed completely in 3 months

  3. tomholub commented on Mar 13, 2023

    @tomholub
    Collaborator

    That leaves Attester to update. can do

  4. changed the title [-]Common API error format[/-] [+]Update API error format on Attester[/+] on Mar 13, 2023
  5. modified the milestones: Discussion, 1.4.3 on Apr 5, 2023
  6. DenBond7 commented on Apr 5, 2023

    @DenBond7
    CollaboratorAuthor

    it looks like we've updated the error format for attester. Now I need to clarify one moment. @tomholub or @martgil Please confirm that error fields(code, message, details) can not be present at the success response(HTTP code 200).

  7. tomholub commented on Apr 5, 2023

    @tomholub
    Collaborator

    that's correct

  8. DenBond7 commented on Apr 5, 2023

    @DenBond7
    CollaboratorAuthor

    @tomholub I have a question. Why do we have different behavior for errors for the following requests?

    https://flowcrypt.com/attester/pub/test@test.test

    image
    image

    ####################################################################################################
    https://flowcrypt.com/attester/pub/test

    image
    image

    Why do we handle them differently?

  9. self-assigned this
    on Apr 5, 2023
  10. tomholub commented on Apr 5, 2023

    @tomholub
    Collaborator

    I'm not sure - the 404 is not really an error in this case, it's a result which means "I searched the pubkey successfully, and none was found"

  11. DenBond7 commented on Apr 5, 2023

    @DenBond7
    CollaboratorAuthor

    Got it. Can we change this behavior? On Android, handling cases with different logic is not simple if we are talking about implementation. IMHO, it will be better to have the same logic over all API if it is possible. To be honest, the best choice will be using JSON even for public key. Like, {"public_key":"..."}. But it seems it's not possible for the particular API.

    So the question is - can we return string only for success case, and JSON for other?

  12. tomholub commented on Apr 5, 2023

    @tomholub
    Collaborator

    I guess we could, but it would be somewhat harder to do it in a backwards compatible manner. I think it would require adding ?format=json or similar.

  13. DenBond7 commented on Apr 5, 2023

    @DenBond7
    CollaboratorAuthor

    I think it would require adding ?format=json or similar

    Sounds good. After these changes code on my side will look much simpler and understandable for other devs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions