Skip to content

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

Closed
dblock wants to merge 1 commit into
slack-ruby:masterfrom
dblock:fix-ai-inference-yaml-indentation
Closed

Fix YAML indentation bug in AI prompt template substitution#88
dblock wants to merge 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.yml workflow's AI commit-message generation step (#87) is fragile: actions/ai-inference@v1 substitutes {{diff_stat}}/{{diff}} placeholders as raw text into the prompt YAML file before parsing it as YAML. Since the diff/diff-stat files were written starting at column 0, injecting multi-line content can break the indentation of the enclosing content: |- block scalar in commit-message.prompt.yml, causing:

##[error]Failed to parse prompt file: bad indentation of a mapping entry

This exact failure mode was confirmed in the sibling workflow in slack-ruby/slack-ruby-client#592 (https://github.com/slack-ruby/slack-ruby-client/actions/runs/31552877245/job/93979138338).

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.

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 commit-message.prompt.yml (which expects continuation
lines to be indented), causing "Failed to parse prompt file: bad
indentation of a mapping entry" at runtime.

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 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #89, which includes this same YAML indentation fix as part of the Copilot CLI migration.

@dblock dblock closed this Aug 12, 2026
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.

1 participant