docs: define time-unit invalid bound error contract

This commit is contained in:
Kari Lintulaakso
2026-03-17 13:57:07 +02:00
parent db013029ef
commit f266609809
3 changed files with 54 additions and 0 deletions
+22
View File
@@ -15,6 +15,28 @@ The components that are used to change the upper or lower time bounds are `TimeB
After the time unit is created, its ID (`tu_name`) is set to be the same as its name, but lowercase (for example, a time unit with the name "Abdounian" has the id "abdounian"). Because of this, changing an existing time unit's name causes a foreign key error in the database because the "now_time_unit" and "now_tau" tables are connected by it. When editing a time unit, the name field is currently disabled to not allow this error to happen.
## Validation behavior for missing bounds
For `PUT /time-unit`, `up_bnd` and `low_bnd` are validated against existing Time Bound records before write operations. If one or both referenced bounds are missing, the request is rejected with `403` and a structured validation array instead of returning `500`.
Example response:
```json
[
{
"name": "Upper Bound",
"error": "Upper bound with ID 40000 does not exist"
},
{
"name": "Lower Bound",
"error": "Lower bound with ID 30000 does not exist"
}
]
```
This contract is intentionally consumable by frontend validation/error-notification logic.
## Problems:
At the moment it seems that Time Units get info about their updates from wrong places. Old PHP-version displays differring data on updates tab. It seems (I might be wrong about this) that PHP-version bases the info on the table now_time_update and the new one on the table now_tau. Prisma doesn't seem to handle the query if based on now_time_update with current schema, but the change should be doable with Prisma's rawSQL.