Repository navigation
fix(skills): strip YAML-decoded null bytes and rotate unwritable catalog rows - #401
Merged
Merged
Conversation
#371 deletes raw NUL from a SKILL.md before parsing, but YAML puts it back: the double-quoted escapes "\0", "\x00" and "\u0000" decode to NUL, and `!!binary` decodes to arbitrary bytes that need not be UTF-8. The catalog backfill then wrote that description and pg refused it with "string contains null byte". Scrubbing the parsed tree in one place covers every consumer: the catalog's name/description, the registry install path, and parse()'s description and frontmatter title that manual skills and templates store. Fixes PALAD-AI-TEMPORAL-1M Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
A row whose write raised was never stamped, so it stayed first in `undescribed_first` and every later run died on it before anything behind it got a turn. One upstream SKILL.md stopped the description backfill and the audit pass for four days. The row is now reported through Rails.error (forwarded to Sentry, one issue per error class), counted as failed and stamped, so the queue moves on. If stamping fails too the database itself is the problem and the run still fails. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Sentry PALAD-AI-TEMPORAL-1M:
ArgumentError: string contains null byteinSkills::CatalogSync#record_metadata. It has failed everyskills_demand_sync_workflowrun since 2026-09-28, and it came back after #371 shipped.Root cause
#371 removes raw NUL bytes from a SKILL.md before parsing it. YAML then puts them back. In double-quoted scalars, the escapes
"\0","\x00"and"\u0000"decode to NUL.!!binarydecodes to arbitrary bytes, which need not be valid UTF-8. I checked all four withYAML.safe_loadon the production Ruby (4.0.7). An upstream SKILL.md uses one of them in its frontmatter, and pg rejects the bind parameter before the UPDATE is sent.Why one file stopped the whole sync
Because the write raised, the row was never stamped with
description_checked_at. It stayed first inundescribed_first, so every later run died on that row before any row behind it got a turn. The description backfill and the audit pass after it both stalled.Changes
Skills::SkillMarkdown:safe_yamlpasses the parsed tree throughscrub_strings. Every string (keys and values, nested) is forced to UTF-8, scrubbed, and has its NUL removed. Doing it in this one place covers every consumer:name/descriptionSkillsRegistryServiceinstallsdescriptionandfrontmatter["title"]fromparse(), which manual skills, personal tools and template installs storeSkills::CatalogSync#backfill_metadata: when a row's write raisesActiveRecord::ActiveRecordErrororArgumentError, the row is now:Rails.errorwith sourceskills.catalog_backfill. It is forwarded to Sentry with one issue per error class and theregistry_idin the context.result.failedIf the stamp fails too, the database itself is the problem and the run still fails.
Tests
skill_markdown_test.rb: all three YAML escapes inname,titleanddescription(throughname,descriptionandparse), plus a!!binarydescription containing NUL and\xFF.catalog_sync_test.rb: an unwritable row at the front of the queue is reported, counted and stamped, and the row behind it still gets its description.I ran each new test against the old code first. All three failed: the markdown tests returned
"pdf\u0000-processing", and the sync test raised the productionArgumentError: string contains null byte.Run locally in an isolated worktree stack: the skills, templates, personal-tools and
SkillsRegistryServicesuites plussentry_configuration_testall pass, and rubocop and brakeman report nothing. CI is the full-suite check.After this deploys, the stuck row is written (or stamped) on the next demand sync and the backlog drains by itself.
🤖 Generated with Claude Code