Skip to content

Fix double-escaped newlines in market metadata TSV cache#5

Merged
moose-code merged 1 commit into
mainfrom
fix-cache-tsv-escapes
Apr 29, 2026
Merged

Fix double-escaped newlines in market metadata TSV cache#5
moose-code merged 1 commit into
mainfrom
fix-cache-tsv-escapes

Conversation

@moose-code

Copy link
Copy Markdown
Member

The backfill script's loadExistingTsv had a buggy unescape (sequential regex replaces interfered with each other), causing every \n / \r / \t escape to gain an extra backslash on each re-write. Each round trip turned \n into \\n in the TSV; postgres COPY then decoded that as literal backslash + LF, which is invalid inside JSON.

Fix: collapse every \\n / \\r / \\t back to the correct \n / \r / \t form. Verified by loading the resulting TSV into postgres without errors (COPY 40308) and round-tripping a sample row through jsonb.

The backfill script's loadExistingTsv had a buggy unescape (sequential
regex replaces interfered with each other), causing every \n / \r / \t
escape to gain an extra backslash on each re-write. Each round trip
turned \\n into \\\n in the TSV; postgres COPY then decoded that as
literal backslash + LF, which is invalid inside JSON.

Fix: collapse every \\\n / \\\r / \\\t back to the correct \\n / \\r /
\\t form. Verified by loading the resulting TSV into postgres without
errors (COPY 40308) and round-tripping a sample row through jsonb.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@moose-code moose-code merged commit c87e8e9 into main Apr 29, 2026
1 check failed
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