evals / account-service
combined-service-failures
Expected
Hidden from the reviewer, like the grading note below.
- ownership
- holds
- database-failures
- violation
- transaction-effects
- violation
Two independent failures occur in service.py. An OSError from the ownership database lookup becomes a successful None return, violating database-failures. The immediate event publication occurs inside the database transaction, so an event can escape before commit or when commit later fails, violating transaction-effects. Ownership still holds: a successful lookup uses the unchanged owner-filtered helper, and the error path returns before the write. Finding either target does not establish the other; report both supported failures without inventing an ownership bypass.
Change
src/service.py
-2+5
1 unmodified line23455678910111210131 unmodified line
async def update_account(db, events, actor_id, account_id, name): try: account = await find_owned_account(db, actor_id, account_id) account = await find_owned_account(db, actor_id, account_id) except OSError: return None if account is None: raise PermissionError("Account unavailable") async with db.transaction(): await db.accounts.rename(account_id, name) await events.publish("account.updated", {"id": account_id}) await events.publish("account.updated", {"id": account_id})Contracts
ownership
---
name: ownership
message: Only update accounts owned by the caller.
---
## Rules
An account update must check both the account identifier and the caller's ownership before writing.
Missing or unauthorized accounts must not reach the write. Ownership checks may live in a helper.
## Checks
Follow the update path and its database query. An account identifier alone is not authorization.
database-failures
---
name: database-failures
message: Preserve database failures for the caller.
---
## Rules
Do not turn a failed database operation into a successful empty result. Propagating or translating
an error into another error is fine. Logging alone does not preserve failure.
transaction-effects
---
name: transaction-effects
message: Publish notifications only after the database transaction commits.
---
## Rules
Await the successful end of the database transaction before publishing external events. A failed
transaction must not publish a notification. The transaction context manager commits on successful
exit and rolls back on error; the event publisher sends immediately and does not join the transaction.