Skip to content

Improve error handling: propagate errors instead of silently swallowing them - #1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783177104-improve-error-handling
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783177104-improve-error-handling

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Several places swallowed errors or returned misleading success responses. This PR surfaces those errors through proper HTTP status codes and explicit failures.

Data integrity — _box_from_row / _order_from_row: Previously used silent fallbacks ("—", "", 0.0) when a referenced partner was missing. Now raises LookupError so data corruption is caught immediately rather than producing ghost records.

Store.create_box: Now validates partner_id exists before inserting the box row. The API layer catches LookupError → HTTP 404.

Store._effective_status: Was except ValueError: pass on malformed pickup_to — silently treating unparseable deadlines as non-expired. Now logs a warning via logger.warning(...) and returns the stored status explicitly.

POST /redeem: Was always HTTP 200 with {"ok": false, ...} for every failure (unknown code, already issued, expired). Now returns 404 (code not found) or 409 (conflict — already issued/expired/refunded).

POST /admin/refund/{order_id}: Was {"refunded": false} with HTTP 200 for both missing orders and invalid-state orders. Now returns 404 or 409 with a reason string. Store.refund return type changed from booltuple[bool, str] to distinguish "not_found" from "invalid_status:{status}".

GET /partners/{id}/boxes and /partners/{id}/orders: Silently returned [] for non-existent partners. Now validates via new Store.partner() method → HTTP 404.

Link to Devin session: https://app.devin.ai/sessions/75d3e7a37fc3462f9ce7b3ed238d8575
Requested by: @wpalish

…ng them

- _effective_status: log malformed pickup_to instead of silently ignoring
- _box_from_row/_order_from_row: raise LookupError on missing partner instead of using fallback values
- create_box: validate partner_id exists before inserting (LookupError → 404)
- partner_boxes/partner_orders: return 404 for non-existent partner_id
- redeem: return 404/409 HTTP errors instead of always 200
- admin_refund: return 404 for missing order, 409 for invalid status (with reason)
- Store.refund: return (success, reason) tuple for richer error info

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@wpalish wpalish self-assigned this Jul 4, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

wpalish pushed a commit that referenced this pull request Jul 16, 2026
…арточка); +контраст футера

По UX-ревью:
- #1 localStorage-нотис был плавающей центр-карточкой (читалось как «глюк»
  поверх секций) → тонкая полоса во всю ширину, приклеена к низу (над bottom-nav
  на мобиле, к краю на десктопе). Показ один раз (флаг ym_cookies уже был).
- #6 контраст копирайта/FAQ-текста в футере поднят (.6→.78, .7→.82 opacity) —
  запас под WCAG AA.
Уже было в коде: #4 срочность («🔥 осталось N» + окно выдачи), #7 соцсети на
светлом --on-ink (не бледные). Требуют ассетов (отдельно): #2 превью карты,
#3 логотипы партнёров/отзывы, #5 лого-марка, #8 PWA-бейджи.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant