fix(preview): unpack all three values returned by _auto_compile_prompts#1721
Open
fmferrari wants to merge 2 commits into
Open
fix(preview): unpack all three values returned by _auto_compile_prompts#1721fmferrari wants to merge 2 commits into
fmferrari wants to merge 2 commits into
Conversation
_auto_compile_prompts() returns a 3-tuple: (compiled_command, compiled_prompt_files, runtime_content) The preview() command was unpacking only 2 values in both its rich-UI path and its fallback except (ImportError, NameError) path, causing apm preview to always crash with: ValueError: too many values to unpack (expected 2) Fix: add _ to capture the unused runtime_content in both call-sites. _execute_script_command already unpacks all three values correctly. Fixes: apm preview <script> crashes for any script definition
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the preview command to match an updated return signature from script_runner._auto_compile_prompts, preventing tuple-unpacking errors during command preview.
Changes:
- Adjusts tuple unpacking to ignore the new third return value from
_auto_compile_prompts. - Adds an inline comment documenting the updated return shape and why only the first two items are used.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
apm preview <script>crashes with:This happens for every script definition regardless of content.
Root Cause
_auto_compile_prompts()insrc/apm_cli/core/script_runner.pyhas return typetuple[str, list[str], str]and always returns three values:_execute_script_command()correctly unpacks all three:But
preview()insrc/apm_cli/commands/run.pyunpacks only two values in both its code paths:tryblock (line ~142)except (ImportError, NameError)fallback path (line ~182)Fix
Add
_to capture the unusedruntime_contentin both call-sites, matching how_execute_script_commandalready handles the return value. Preview does not execute the script, soruntime_contentis not needed.Reproduction
Any
apm.ymlwith ascripts:block:Tested against APM 0.19.0.