Skip to content

bug: Parsing of zebrad.toml on Windows fails due to Byte Order Mark (BOM) added to the beginning of the file #10561

Description

@Anynomouss

What happened?

I expected to zebra to be able to load the config file it created itself on Windows:
When generating a zebrad.toml and loading it:

.\zebrad.exe generate > zebrad.toml 
C:\Users\$USER$\AppData\Local\zebrad.toml

The generate file is not parsed properly because of BOM markers added at the beginning of the file resulting into an error

error: Zebra could not load the provided configuration file and/or environment variables.This might mean you are using a deprecated format of the file, or are attempting to
configure deprecated or unknown fields via environment variables.You can generate a valid config by running "zebrad generate", and diff it against yours to examine any format inconsistencies.
error: zebrad fatal error: I/O operation failed: Configuration error: TOML parse error at line 1, column 3
|
1 | ��# Default configuration for zebrad.

When opening the file in a hex editor it shows FF FE BOM markers are added by Windows since it by default generates text files with Byte Order Mark (BOM) for UTF-16 Little Endian. It would be better to scan for these bytes and skip or remove them. The zebrad.toml config would be loaded normally on Windows. Opening the file with Notepad++, going to encoding and saving as UTF-8 (without BOM) manually fixes the issues. An easy fix would be to ignore errors from the first line, or ignore errors in lines that do not contain '=' since those are comments and not relevant for loading config parameters.

Zebra Version

4.4.1

Which operating systems does the issue happen on?

  • Linux
  • macOS
  • Windows
  • Other OS

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cliArea: Command-line interfaces and processesC-bugCategory: This is a bugI-usabilityZebra is hard to understand or useS-needs-designStatus: Needs a design decisionS-needs-triageStatus: A bug report needs triageai-generatedThis is a temporary label for using AI to clear some of our backlog.external-contribution

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions