Repository navigation
Suggest container builds for missing Python dependencies - #987
Open
dhunganapramod9 wants to merge 1 commit into
Open
dhunganapramod9 wants to merge 1 commit into
dhunganapramod9 wants to merge 1 commit into
Conversation
bnusunny
approved these changes
Dec 3, 2026
bnusunny
left a comment
Contributor
There was a problem hiding this comment.
Thanks for picking up #208. The change is small and safe: only MissingDependencyError gets the hint, every other PackagerError keeps its current message, and the original error stays chained (from ex). The parameterized test covers both paths, and CI is green. Approving.
Non-blocking suggestions, fine as follow-ups:
- Readable dependency list.
MissingDependencyErroris raised withpackages_without_wheels, a set ofPackageobjects, and it doesn't pass a message tosuper().__init__, sostr(ex)is the raw set repr (e.g.{markupsafe==3.0.3(sdist)}). That predates this PR, but now that the message is user-facing, consider formattingex.missingas a list of names before the hint. - Hint inside a container build. If the user already runs
sam build --use-container, a missing wheel isn't a host-platform problem, and "trysam build --use-container" points the wrong way. lambda-builders can't tell, so softer wording such as "If you are not already building in a container..." would avoid that. - Machine-readable errors. SAM CLI's
sam build --output jsonreports failures as{"error": {"type", "message", "resources"}}, wheretypeis the lambda-builders exception class name. BecauseWorkflow.runre-wraps everyActionFailedErrorintoWorkflowFailedError, this case shows up as"type": "WorkflowFailedError", the same as any other build failure, and the hint and package list exist only as free text inmessage. For agents and scripts to act on it, a follow-up could carry a distinct error type (e.g. keepMissingDependencyError, withmissingas a list of names) through the workflow so SAM CLI can expose it, and let SAM CLI add the--use-containersuggestion as its own field, since it knows whether the build already ran in a container. Not needed for this PR. - Test input. The test builds
MissingDependencyError(["native-package==1.0"])from a list;build_dependenciesactually raises it with a set ofPackageobjects. A case using that shape would cover point 1.
Please also add Fixes #208 to the description so the issue closes on merge.
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.
Issue #, if available: #208
Description of changes
When the Python pip builder cannot package a dependency, keep the dependency details and add a conditional hint for native compilation. The hint suggests a Lambda-compatible Linux environment and points SAM CLI users to
sam build --use-container. Other pip packaging errors keep their existing message.Description of how you validated changes
LambdaBuilderon Windows with Python 3.12 and a local wheelhouse containing only the Windows wheel for MarkupSafe 3.0.3. Both versions report the missing dependency. The patch adds the container hint.git diff --checkpassed. The full local unit and functional run reached 94.39% coverage and had the same 24 failures as unmodifieddevelopon this Windows machine.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.