QKeyDB textRecordsExtension crashes on every line when asRecords is true
TypeError: Cannot read properties of undefined (reading 'trim') in parseBlockStructuredText when asRecords: true
The qkey_commercial textRecordsExtension's parseBlockStructuredText used line.split(':', 1) to split each key: value line, which crashes immediately because Array.prototype.split(separator, limit) truncates the RESULT ARRAY to limit elements rather than splitting into limit+1 parts - so the second destructured variable was always undefined, meaning the asRecords:true feature never worked at all for any caller.
Root Cause
line.split(':', 1) returns an array truncated to 1 element (just the text before the first colon), not a 2-element [key, value] pair as the code assumed. This is a common split()-API misunderstanding: the limit parameter caps the OUTPUT array length, it does not mean 'split on the Nth occurrence.'
Solution Steps
- Replace const [rawKey, rawValue] = line.split(':', 1) with const firstColon = line.indexOf(':'); const rawKey = line.slice(0, firstColon); const rawValue = line.slice(firstColon + 1); so the full value (including any embedded colons, e.g. in URLs) is preserved.
- Add an isQuoted() guard so metadata value coercion only applies to unquoted values - previously an explicitly quoted string like version: "1.0" was coerced the same as an unquoted numeric-looking value, silently corrupting it into the number 1.
- Run the dedicated test file covering brace-block record extraction.
Validation
[object Object]
Rollback
[object Object]
Ecosystem: qkeydb
License: CC-BY-4.0
Last updated: Jul 6, 2026