Altinn / Altinn/app-lib-dotnet

Using API to get a data element that doesn't exist responds with 500 instead of 404

Open
#889 0 comments 0 reactions 0 assignees View on GitHub
kind/bug status/triage
Dominant language
C#
Stars
8
Forks
27
Avg merge
1h 21m
Merged PRs (30d)
7

Description

### Description of the bug

If I have a valid user logged in, that has created an instance with a valid instanceId, and I ask for an not existing but valid data id on the data/{dataGuid} GET endpoint, the server responds with 500 internal server error.

Expected behavior: The server should respond with a 404 not found, as I'm asking for an element that doesn't exist. Potentially a 403 bad request. This works properly if the request is not a properly formatted guid, but with proper guid formatting the server assumes it made a mistake.

### Steps To Reproduce

1. Authenticate as a test user with access to vpfo : `user_id: 160616; party_id: 51882621`
2. Create instance: `POST https://brg.apps.tt02.altinn.no/brg/aarsregnskap-vpfo-202405/instances?instanceOwnerPartyId=51882621`
3. Get data element with a valid Guid that does not exist: `GET https://brg.apps.tt02.altinn.no/brg/aarsregnskap-vpfo-202405/instances/51882621/{{schema_instance_id}}/data/82a351d9-807f-4949-9d6b-3cc7eea38a17`
4. The server will respond with 500

### Additional Information
The bug is not exclusive to VPFO, and should be reproduceable with any app / data element

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the GET /instances/{instanceOwnerPartyId}/{instanceId}/data/{dataGuid} request with a valid, nonexistent GUID, as described in the issue. Trace the resulting 500 response to the API error handling and verify that a missing data element returns 404 without changing the behavior for malformed GUIDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.