Writing

Notes from shipping
production code

Short writeups on bugs I've fixed in open-source projects, patterns I've learned building AI-powered systems at work, and the kind of subtle software behaviour that's only visible from the trenches.

All Posts

One schema, every mimetype: the shared-reference bug in NestJS Swagger's content wrapper

Declare a response for two media types and NestJS Swagger handed both the same object — content['application/json'] === content['application/xml'] was true. Mutate one, both change, and your input gets chewed too. An aliasing bug where the fix is one cloneDeep, and the real deliverable is the spec that states the invariants.

Why VS Code said 'Cannot redeclare block-scoped variable' on valid HTML: every script tag is one virtual file

VS Code's HTML language server validates all your script tags as one concatenated virtual JavaScript file — one shared scope. The browser runs a type="module" script in its own scope, so a perfectly valid page threw a false redeclaration error for two years. The fix models the scopes the runtime actually creates.

Why Swagger UI was crashing on a valid OpenAPI spec: an unguarded .getIn() chain

A 5-line fix in Swagger UI's spec selector. An unguarded Immutable.js .getIn(['content']) chain crashed the browser render on a valid-but-unusual OpenAPI 3.0 spec — a codegen-emitted requestBody with no content field. The lesson generalizes: any schema-optional field is the reader's problem.

Why editing a README was rebuilding my entire NestJS project: an inverted chokidar filter

A 2-line fix in NestJS CLI's SWC watcher. Two layered bugs in one predicate: a string-format mismatch on file extensions, plus an inverted boolean that turned the ignored filter into an included filter. A README save was triggering full TypeScript recompilation.

BullMQ was crashing on getRanges() because Python's list.reverse() returns None

A 1-line fix in BullMQ's Python port that turned on the universal lesson about Python's mutating-vs-returning method conventions. .reverse(), .sort(), .append() — they all mutate in place and return None.

The bug where VS Code's Debug Console was pasting 'repl:1' into my clipboard

A 2-line CSS fix in VS Code that taught me how user-select: text cascades through every descendant — even the decorative ones. The fix for my own misread of the bug: stop looking at JavaScript, start looking at the cascade.