OpenFn / OpenFn/lightning

Improve API error codes

Open
#715 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
296
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
50

Description

User story

As a user that is making a request to the JSON API with an invalid token, I would like to receive a 401 response, so that I know that I've got an authentication issue, and I can resolve the problem faster.

As a user that is making a request to the JSON API with invalid data, I would like to receive a 400 response, so that I know that I've got an issue with my request data, and I can resolve the problem faster.

Details

Currently, the JSON API returns a 500 error code if the authentication token is incorrect.

We should be adding the following error codes to the JSON API:
400—Bad Request.
401—Unauthorized.
403—Forbidden <-- @stuartc do we have any POST requests in our JSON API yet? If not then there would be no need for 403 at the moment.

Implementation notes
Release notes
  • Add authentication and bad request error codes to the JSON API
User acceptance criteria
  • When I make an API request with an invalid token, I receive a 401 error code
  • When I make an API request with a valid token and valid data, I receive a 200 response
  • When I make a request with a valid token but invalid data, I receive a 400 response
  • When I make a request with

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names the JSON API but no files, tests, or entry points; start by tracing how it handles invalid tokens and invalid request data. Done means invalid tokens return 401, invalid data returns 400, valid requests retain 200, and the need for 403 is resolved based on current POST support.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
api, authentication, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.