Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Budget Guard Refunded Twice, So the Batch Outlived Its Cap

The short version: my token budget guard refunded the same reservation on every retry. The counter drifted upward, the batch ran past its cap, and half the shards died at the worst moment. The fix was one rule: a reservation can be closed exactly once. One note before we start. The log shapes below are rebuilt from a synthetic repro, not a customer run. The pattern is real. The numbers are…

The budget guard system refunded the same reservation on every retry, causing the batch to surpass its capacity limit and half of the shards to fail. The fix was to allow a reservation to be closed exactly once. The log shapes were rebuilt from a synthetic reproduction, not a real customer run, but the pattern was real. The numbers were illustrative, with the alert showing 78% and the provider indicating 100%.

The batch stopped at 04:10, with three of twelve shards failing due to quota errors. The local counter showed 78% of the budget consumed, while the provider dashboard revealed a full 100% usage. Both numbers stemmed from the same run, but only one was accurate. The question arose: which one should we trust when the tool we built is the one deceiving us?

The answer is clear – trust the ledger, not the counter. The initial approach was to stop counting and start logging. A single integer cannot be debugged, as it has no history or owner. Therefore, the counter was replaced with an append-only event log, where every state change writes a single line. The log contained three event types: reserve when a call starts, settle when real usage is known, and refund when nothing was consumed.

The reservation identity (rid) was crucial, as it was where the bug was hiding. The replay of the ledger proved more productive than rereading the code. The events were parsed and counted, revealing 412 reserves and 449 refunds. This discrepancy between refunds and reserves indicated the bug, as no accounting system can refund more often than it reserves.

This single line of output exposed the entire issue. Furthermore, only one of the two refund call sites was identified, revealing the root cause of the problem.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Salon, One of the Web's Pioneering News Outlets, Shuts Down After 31 Years

"It has been an extraordinary privilege," says the subheading on Thursday's announcement. After 31 years Salon.com will stop publishing, according to an announcement which appeared on the site under…

  • Salon closes after 31 years of pioneering web journalism
  • 19 full-time employees affected by closure
  • Founded in 1995 to reshape journalism on the internet

Human as a Tool: The Agent Pattern Where You Work for the Machine

There's an agent design pattern with an uncomfortable premise: the agent is the orchestrator, and you are one of its tools.

  • Human-as-a-tool pattern treats humans as integral components of machine operation.
  • Implementation involves simple tool definition with human operator response to specific questions.

Node.js Secure Direct Browser Uploads for Generic Gaming Files (Object Storage at Scale)

Large product-image batches change this decision: the browser should send bytes to storage, while the Node.js application issues narrow, tenant-scoped permission and stays out of the data path.

  • Node.js acts as intermediary for secure direct browser uploads of gaming files.
  • Browser transfers bytes directly to object storage, minimizing Node.js server involvement.

More from Sunday 8 November →