Skip to content

Fix YAML indentation bug in AI prompt template substitution - #592

Merged
dblock merged 1 commit into
slack-ruby:masterfrom
dblock:fix-ai-inference-yaml-indentation
Aug 12, 2026
Merged

Fix YAML indentation bug in AI prompt template substitution#592
dblock merged 1 commit into
slack-ruby:masterfrom
dblock:fix-ai-inference-yaml-indentation

Conversation

@dblock

@dblock dblock commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Problem

The update_api.yml workflow's new AI CHANGELOG generation step (#591) fails on the first real scheduled run:

Generate changelog entries with AI	Using prompt YAML file format
Generate changelog entries with AI	##[error]Failed to parse prompt file: bad indentation of a mapping entry (29:2)

https://github.com/slack-ruby/slack-ruby-client/actions/runs/31552877245/job/93979138338

Root cause

actions/ai-inference@v1 substitutes {{diff_stat}}/{{diff}} placeholders as raw text into the prompt YAML file before parsing it as YAML. The diff/diff-stat files were written starting at column 0, so injecting their multi-line content broke the indentation of the enclosing content: |- block scalar in changelog-entries.prompt.yml.

Fix

Pipe the diff/diff-stat output through sed 's/^/ /' (6 spaces, matching the prompt file's block scalar indentation) before writing them to the files consumed via file_input, so the substituted content stays inside the block and parses correctly.

Verified by simulating the exact template substitution locally with yaml.safe_load after applying the fix.

actions/ai-inference@v1 substitutes {{var}} placeholders as raw text
into the prompt YAML file before parsing it as YAML. Since the diff/
diff-stat files started at column 0, injecting their multi-line
content broke the indentation of the enclosing `content: |-` block
scalar in changelog-entries.prompt.yml (which expects continuation
lines to be indented), causing "Failed to parse prompt file: bad
indentation of a mapping entry" at runtime, e.g.:

https://github.com/slack-ruby/slack-ruby-client/actions/runs/31552877245/job/93979138338

Indent every line of the diff/diff-stat files with 6 spaces (to
match the prompt file's block scalar indentation) before writing
them out, so the substituted content stays inside the block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock
dblock force-pushed the fix-ai-inference-yaml-indentation branch from 18a4e05 to 3d466cf Compare August 12, 2026 01:18
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock
dblock merged commit 2d66c31 into slack-ruby:master Aug 12, 2026
10 checks passed
@dblock
dblock deleted the fix-ai-inference-yaml-indentation branch August 12, 2026 01:19
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31553155612

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage remained the same at 91.055%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 5746
Covered Lines: 5232
Line Coverage: 91.05%
Coverage Strength: 100.24 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants