SciCatProject / SciCatProject/backend

HTTP GET on non-existing proposal returns empty content

Open
#842 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
27
Forks
37
Avg merge
17h 32m
Merged PRs (30d)
38

Description

Summary

Using the REST API to get a non-existing proposal through /api/v3/proposals/{pid} returns with HTTP status code 200 and empty content.

From an interactive Python session:

>>> res = client._session.get(f'{client.baseurl}/proposals/does_not_exist')
>>> res.url
'https://scicat-backend-dev.desy.de/api/v3/proposals/does_not_exist'
>>> res.status_code
200
>>> res.content
b''

As a workaround, I am checking for empty content to determine, if the proposal already exists. Using the HTTP status code would be preferred.

Steps to Reproduce
  • Authenticate as proposalIngestor through the API
  • Call /api/v3/proposals/{pid}, where {pid} refers to a non-existing proposal
  • Receive HTTP status code 200 and empty response
Current Behaviour

API call returns HTTP status code 200 and empty content in the response

Expected Behaviour

API should return HTTP status code 404 not found.

Contributor guide

Open the contributing guide

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

Start at the REST endpoint handling GET /api/v3/proposals/{pid} and reproduce the request for a non-existing proposal as proposalIngestor. Trace how the empty response is produced and verify that the missing proposal returns HTTP 404 rather than 200 with empty content. Done means the expected status is returned consistently, with a regression test if the project has endpoint tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.