BUG-HUNT: [boundary] YAML template post-processing fails on complex colon-containing values #7147

Open
opened 2026-04-10 08:11:18 +00:00 by HAL9000 · 1 comment
Owner

Background and Context

The YAMLTemplateEngine's _postprocess_rendered_yaml() and _fix_common_yaml_issues() methods contain fragile string parsing logic that incorrectly handles YAML values containing multiple colons. This causes malformed YAML structure and parse failures when actor YAML configurations include values with colon characters — a common occurrence in URLs, timestamps, namespaced identifiers, and template expressions.

This bug was discovered during boundary testing of the actor YAML configuration pipeline.

Current Behavior (Bug)

When a YAML template value legitimately contains colon characters, the post-processing logic incorrectly splits on all colons instead of properly parsing YAML structure. For example:

key1: value with spaces: and more colons
key2: {{ 'value with : colon' }}

Results in:

yaml.scanner.ScannerError: mapping values are not allowed here

The string-based colon splitting in _postprocess_rendered_yaml() and _fix_common_yaml_issues() treats every : as a key-value separator, corrupting valid YAML that happens to contain colons in its values.

Location:

  • File: src/cleveragents/actor/yaml_template_engine.py
  • Functions: _postprocess_rendered_yaml(), _fix_common_yaml_issues()
  • Approximate lines: ~130–180

Expected Behavior

Post-processing should preserve valid YAML structure and only fix actual template-related formatting issues. It must not break valid YAML syntax when values legitimately contain colon characters (e.g., URLs, timestamps, namespaced actor references, Jinja2 filter expressions).

Reproduction Steps

  1. Create an actor YAML configuration with a value containing a colon:
    name: local/my-actor
    description: "Connects to https://api.example.com: the main endpoint"
    
  2. Pass it through YAMLTemplateEngine.render().
  3. Observe ScannerError: mapping values are not allowed here raised during post-processing.

Suggested Fix

  1. Replace string-based colon splitting with proper YAML parsing (e.g., use ruamel.yaml or PyYAML's round-trip loader for structure-aware post-processing).
  2. Implement AST-based post-processing that understands YAML structure rather than operating on raw strings.
  3. Add comprehensive BDD test scenarios for edge cases with special characters (colons, quotes, braces, pipes) in YAML template values.

Metadata

  • Branch: bugfix/m3-yaml-template-colon-postprocessing
  • Commit Message: fix(actor): replace fragile string-based colon splitting in YAML template post-processing
  • Milestone: (none — backlog)
  • Parent Epic: #5502

Subtasks

  • Reproduce the bug with a minimal failing BDD scenario (tagged @tdd_issue, @tdd_issue_<N>, @tdd_expected_fail)
  • Audit _postprocess_rendered_yaml() for all string-split-on-colon patterns
  • Audit _fix_common_yaml_issues() for all string-split-on-colon patterns
  • Replace string manipulation with structure-aware YAML parsing
  • Add BDD scenarios: colon in value, colon in quoted string, colon in Jinja2 expression, URL values
  • Add Robot Framework integration test for actor config with colon-containing values
  • Verify coverage ≥ 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly: fix(actor): replace fragile string-based colon splitting in YAML template post-processing
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly: bugfix/m3-yaml-template-colon-postprocessing
  • The commit is submitted as a pull request to master, reviewed, and merged.
  • All nox stages pass (nox with no arguments).
  • Coverage ≥ 97%.
  • The @tdd_expected_fail tag has been removed from all @tdd_issue_<N> scenarios for this issue (per Bug Fix Workflow).

Backlog note: This issue was discovered during autonomous operation
on milestone v3.2.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: Acting on behalf of: UAT Testing | Agent: new-issue-creator

## Background and Context The `YAMLTemplateEngine`'s `_postprocess_rendered_yaml()` and `_fix_common_yaml_issues()` methods contain fragile string parsing logic that incorrectly handles YAML values containing multiple colons. This causes malformed YAML structure and parse failures when actor YAML configurations include values with colon characters — a common occurrence in URLs, timestamps, namespaced identifiers, and template expressions. This bug was discovered during boundary testing of the actor YAML configuration pipeline. ## Current Behavior (Bug) When a YAML template value legitimately contains colon characters, the post-processing logic incorrectly splits on all colons instead of properly parsing YAML structure. For example: ```yaml key1: value with spaces: and more colons key2: {{ 'value with : colon' }} ``` Results in: ``` yaml.scanner.ScannerError: mapping values are not allowed here ``` The string-based colon splitting in `_postprocess_rendered_yaml()` and `_fix_common_yaml_issues()` treats every `:` as a key-value separator, corrupting valid YAML that happens to contain colons in its values. **Location:** - File: `src/cleveragents/actor/yaml_template_engine.py` - Functions: `_postprocess_rendered_yaml()`, `_fix_common_yaml_issues()` - Approximate lines: ~130–180 ## Expected Behavior Post-processing should preserve valid YAML structure and only fix actual template-related formatting issues. It must not break valid YAML syntax when values legitimately contain colon characters (e.g., URLs, timestamps, namespaced actor references, Jinja2 filter expressions). ## Reproduction Steps 1. Create an actor YAML configuration with a value containing a colon: ```yaml name: local/my-actor description: "Connects to https://api.example.com: the main endpoint" ``` 2. Pass it through `YAMLTemplateEngine.render()`. 3. Observe `ScannerError: mapping values are not allowed here` raised during post-processing. ## Suggested Fix 1. Replace string-based colon splitting with proper YAML parsing (e.g., use `ruamel.yaml` or `PyYAML`'s round-trip loader for structure-aware post-processing). 2. Implement AST-based post-processing that understands YAML structure rather than operating on raw strings. 3. Add comprehensive BDD test scenarios for edge cases with special characters (colons, quotes, braces, pipes) in YAML template values. ## Metadata - **Branch**: `bugfix/m3-yaml-template-colon-postprocessing` - **Commit Message**: `fix(actor): replace fragile string-based colon splitting in YAML template post-processing` - **Milestone**: *(none — backlog)* - **Parent Epic**: #5502 ## Subtasks - [ ] Reproduce the bug with a minimal failing BDD scenario (tagged `@tdd_issue`, `@tdd_issue_<N>`, `@tdd_expected_fail`) - [ ] Audit `_postprocess_rendered_yaml()` for all string-split-on-colon patterns - [ ] Audit `_fix_common_yaml_issues()` for all string-split-on-colon patterns - [ ] Replace string manipulation with structure-aware YAML parsing - [ ] Add BDD scenarios: colon in value, colon in quoted string, colon in Jinja2 expression, URL values - [ ] Add Robot Framework integration test for actor config with colon-containing values - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly: `fix(actor): replace fragile string-based colon splitting in YAML template post-processing` - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly: `bugfix/m3-yaml-template-colon-postprocessing` - The commit is submitted as a **pull request** to `master`, reviewed, and **merged**. - All nox stages pass (`nox` with no arguments). - Coverage ≥ 97%. - The `@tdd_expected_fail` tag has been removed from all `@tdd_issue_<N>` scenarios for this issue (per Bug Fix Workflow). > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Acting on behalf of: UAT Testing | Agent: new-issue-creator
Author
Owner

Verified — Bug: YAML template post-processing fails on complex colon-containing values. MoSCoW: Should-have. Priority: Medium.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Bug: YAML template post-processing fails on complex colon-containing values. MoSCoW: Should-have. Priority: Medium. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#7147
No description provided.