Description
notion db add-bulk <db-id> --file items.json fails to parse a JSON file that has a UTF-8 BOM (EF BB BF bytes at the start). Error:
Error: parse JSON: invalid character 'ï' looking for beginning of value
(expected array of {"Key": "Value"} objects)
The character ï is what the BOM bytes look like when interpreted as Latin-1.
Repro on Windows
# PowerShell 5.1 defaults to UTF-8-with-BOM when writing JSON files
$items = @(@{ Name = "test"; Status = "TBD" })
$items | ConvertTo-Json | Out-File -Encoding utf8 items.json
notion db add-bulk <db-id> --file items.json
# → Error: parse JSON: invalid character 'ï' ...
Workaround
Write the file without BOM:
[System.IO.File]::WriteAllText(
"items.json",
($items | ConvertTo-Json),
(New-Object System.Text.UTF8Encoding $false)
)
Expected
The JSON parser should skip a leading UTF-8 BOM. This is a common Windows export artifact and most modern JSON parsers handle it transparently.
In Go, the typical fix is:
data, _ := os.ReadFile(path)
data = bytes.TrimPrefix(data, []byte("\xef\xbb\xbf"))
// then json.Unmarshal(data, ...)
Environment
- OS: Windows 11
- Shell: PowerShell 5.1 (writes UTF-8 with BOM by default)
- notion-cli: v0.7.0
Impact
Real friction on Windows. Bulk adds and other --file commands are blocked until the user finds the right encoding incantation.
The same problem likely affects all --file flags that read JSON (db query --filter-json @file, api ... --body @file, etc. if any). Worth fixing in a shared input-loading helper.
Description
notion db add-bulk <db-id> --file items.jsonfails to parse a JSON file that has a UTF-8 BOM (EF BB BFbytes at the start). Error:The character
ïis what the BOM bytes look like when interpreted as Latin-1.Repro on Windows
Workaround
Write the file without BOM:
Expected
The JSON parser should skip a leading UTF-8 BOM. This is a common Windows export artifact and most modern JSON parsers handle it transparently.
In Go, the typical fix is:
Environment
Impact
Real friction on Windows. Bulk adds and other
--filecommands are blocked until the user finds the right encoding incantation.The same problem likely affects all
--fileflags that read JSON (db query --filter-json @file,api ... --body @file, etc. if any). Worth fixing in a shared input-loading helper.