1
0

Taiga#457: improve bookingitem resource mapping error message (#218)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/218
Reviewed-by: Marc Sandlus <hsh-marcsandlus@noreply.dev.hostsharing.net>
This commit is contained in:
Michael Hoennig
2026-03-19 09:40:14 +01:00
parent 69e2fc09a6
commit 79d4d8c7f2
13 changed files with 139 additions and 20 deletions
@@ -0,0 +1,63 @@
# PR#218: Bad error message for string instead of JSON
This PR contains an unrelated quickfix, see [Additional Changes](#additional-changes) below.
## The Problem
This request:
```
$ curl --no-progress-meter -X 'POST' \
'https://backend.ngdev.hostsharing.net/api/hs/booking/items' \
-H 'Accept: application/json' \
-H "Authorization: Bearer $BEARER" \
-H "Origin: http://127.0.0.1:3001" \
-H 'Content-Type: application/json' \
-d '{
"project.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"parentItem.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"type": "PRIVATE_CLOUD",
"caption": "string",
"validTo": "2026-03-18",
"resources": "string",
"hostingAsset": {
"parentAsset.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"assignedToAsset.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"type": "CLOUD_SERVER",
"identifier": "string",
"caption": "string",
"alarmContact.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"config": "string",
"subHostingAssets": [
{
"type": "CLOUD_SERVER",
"identifier": "string",
"caption": "string",
"assignedToAsset.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"alarmContact.uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"config": "string"
}
]
}
}' \
|jq|less
```
responses with this unclear error message:
```json
{
"timestamp": "2026-03-18 03:59:56",
"path": "",
"statusCode": 500,
"statusPhrase": "Internal Server Error",
"message": "ERROR: [500] Map expected, but got: string"
}
```
## The Solution
Fortunately, in this case, it's a union (anyIf) at the API level (OpenAPI specification).
Thus, it cannot be parsed by the Spring Framework, but we parse it ourselves,
and I was able to simply pass the related property name and improve the error message.
+53
View File
@@ -0,0 +1,53 @@
# Pull-Request Documentations in doc/PR
This directory contains documentation for each pull request (PR).
## Naming Convention
1. Date of the PR in the format `YYYY-MM-DD`
2. followed '-PR#' followed by the number of the pull request in GitEA,
3. a short description of the PR with dashes between the words,
4. '.md'
Yes, for this you need to open a pull request,
but initially prefix its title with "WIP: " to mark it as a work in progress until it is ready for review.
## Guidelines
- Documentations must be written in Markdown format.
- Use Englisch, it's a public open source project.
- Use clear and concise language and keep it short.
- Include relevant details and context.
- Do not reference to Taiga or any other tool that is not public.
- If necessary, copy important parts of the ticket description.
- One sentence or statement per line to make diffs easier to read.
## Structure
```Markdown
## The Problem
Here you describe what this PR is supposed to solve.
## The Solution
Here you describe the changes you made and why you made them.
If necessary, you can link to an ADR (Architecture Decision Record).
## Additional Changes
Here you list any additional changes you made, e.g. "fixed formatting in ..." or "fixed some naming issues".
## Attachments
Here you can add any longer sections that would interrupt the reading flow in the previous sections.
Put each attachment on a level-3 heading ('### ...').
```