mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-01-15 05:33:26 +01:00
Null category handling - API crashes when serializing transactions with null categories #81
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SerafimPikalov on GitHub (Dec 7, 2025).
When a transaction has no category assigned (
category=None), the API serializer crashes with anAttributeErrorwhen trying to serialize the transaction.Steps to Reproduce:
null/api/transactions/{id}/Expected Behavior:
Transactions without categories should serialize successfully, returning
category: nullin the JSON response.Actual Behavior:
API crashes with
AttributeError: 'NoneType' object has no attribute 'id'when trying to accessvalue.idon a None category.@SerafimPikalov commented on GitHub (Dec 7, 2025):
Pull request to fix it: https://github.com/eitchtee/WYGIWYH/pull/428
Solution could be questionable because change validation shems, but works for me
@eitchtee commented on GitHub (Dec 7, 2025):
Thank you for the report and the fix, but I can't seem to reproduce this locally or on a production environment.
Setting category to null raises a 400 error, which makes sense considering the schema, but could probably be changed since categories are indeed nullable.
And GETting a transaction with a null category just works.
Do you have some reproducible curls commands (or something else)?
@SerafimPikalov commented on GitHub (Dec 7, 2025):
I’m out of code right now and can’t test it, but it should be pretty close to these ones:
First, create a transaction without a category:
curl -X POST http://127.0.0.1:9005/api/transactions/
-u "login:pass"
-H "Content-Type: application/json"
-d '{
"account_id": 1,
"date": "2025-02-03",
"amount": "123.45",
"description": "Example purchase",
"type": "EX",
"is_paid": true
}'
Set prexisted category:
curl -X PATCH http://127.0.0.1:9005/api/transactions/1234/
-u "login:pass"
-H "Content-Type: application/json"
-d '{"category": "Groceries"}'
@eitchtee commented on GitHub (Dec 7, 2025):
Yeah, no luck on my side.
However the fix is solid and shouldn't cause any problems.