Skip to content

generated .toml command files fail to parse when a description or body contains a control character #3340

Description

@Quratulain-bilal

both toml renderers write control characters into the output raw, which produces a .toml file that a parser rejects.

toml forbids literal control characters (U+0000-U+001F except tab and newline, plus U+007F) in every string form, and a bare carriage return that is not part of a CRLF pair.

two separate code paths hit this:

  • TomlIntegration._render_toml_string in src/specify_cli/integrations/base.py, used by the gemini and tabnine integrations for the description and prompt fields.
  • CommandRegistrar.render_toml_command / _render_basic_toml_string in src/specify_cli/agents.py, used for extension/preset command files.

the multiline """ and ''' forms and the basic-string fallback all emit the control char verbatim, so the resulting file cannot be loaded back.

repro (either renderer):

import tomllib
from specify_cli.integrations.base import TomlIntegration
rendered = TomlIntegration._render_toml_string("ab")
tomllib.loads(f"prompt = {rendered}")  # tomllib.TOMLDecodeError: Illegal character

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions