| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Sorry, something went wrong.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 61535768-f87c-4e73-898d-e21cf514e164 📥 CommitsReviewing files that changed from the base of the PR and between 60f04e1 and fb232ca. 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 Walkthrough WalkthroughThis PR adds support for multiple named Lambda layers from separate Python requirements files through custom.pythonRequirements.layers. It adds validation, per-layer installation and packaging, tests, documentation, and an integration fixture. ChangesNamed Python Lambda Layers
Estimated code review effort: 3 (Moderate) | ~30 minutes Merge Risk: ⚪ Minimal · up to fb232 This adds named Python dependency layers while preserving the existing single-layer configuration. Invalid inputs and layer-name conflicts are handled before packaging, and the supplied tests cover packaging output and failure paths; no merge-blocking risk is identified. Sequence Diagram(s)sequenceDiagram
participant ServerlessConfig
participant PythonPlugin
participant RequirementsInstaller
participant LambdaLayers
ServerlessConfig->>PythonPlugin: custom.pythonRequirements.layers
PythonPlugin->>RequirementsInstaller: install each requirements file
RequirementsInstaller-->>PythonPlugin: per-layer working directory
PythonPlugin->>PythonPlugin: create per-layer zip archive
PythonPlugin->>LambdaLayers: register named layer resources
Suggested reviewers: czubocha 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)docs/sf/providers/aws/guide/python.md (1)🤖 Prompt for all review comments with AI agentspackages/serverless/lib/plugins/python/index.js (1)342-358: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Minor: combined example block breaks from surrounding doc convention.
The preceding "Lambda Layer" section splits custom and functions config into separate YAML blocks; this new example merges both into one, which is a small stylistic inconsistency.
🤖 Prompt for AI AgentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/sf/providers/aws/guide/python.md` around lines 342 - 358, The new Python layer example in the AWS guide breaks the existing documentation style by merging the `custom` and `functions` sections into a single YAML block. Update the example near the `pythonRequirements` and `api` configuration so it matches the surrounding “Lambda Layer” convention: keep the `custom` configuration and the `functions` configuration as separate YAML snippets while preserving the same `PydanticLambdaLayer` and `WebLambdaLayer` references.127-132: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
Invalid options.layers is silently dropped without any warning.
When custom.pythonRequirements.layers is misconfigured (not an object, or an array), it's deleted with no log message. Elsewhere in this same getter, misconfiguration (dockerImage+dockerFile) throws, and docker-related misconfig triggers this.warningLogged/this.log.warning. A user who accidentally sets layers to the wrong shape will see no layers built and no explanation why.
💡 Suggested fix: warn on invalid shape🤖 Prompt for AI Agentsif ( options.layers != null && (typeof options.layers !== 'object' || Array.isArray(options.layers)) ) { + if (this.log) { + this.log.warning( + 'custom.pythonRequirements.layers must be an object map of layer definitions; ignoring invalid value.', + ) + } else { + this.serverless.cli.log( + 'WARNING: custom.pythonRequirements.layers must be an object map of layer definitions; ignoring invalid value.', + ) + } delete options.layers }Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/serverless/lib/plugins/python/index.js` around lines 127 - 132, The invalid options.layers handling in pythonRequirements should not silently delete misconfigured values; update the getter in the Python plugin to emit a warning before removing layers when it is not an object or is an array. Follow the existing validation patterns used nearby in this same getter, such as the dockerImage/dockerFile conflict and docker-related warning logic, and use this.warningLogged or this.log.warning so users know their custom.pythonRequirements.layers setting was ignored.
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@packages/serverless/lib/plugins/python/lib/layer.js`: - Around line 126-131: The empty-requirements fast path in the layer zip flow only checks requirementsTxtPath with fse.existsSync, so a zero-byte requirements.txt still falls through and gets packaged. Update the branch in the layer.js logic that builds the rootZip/writeZip path to treat an empty requirements.txt the same as a missing one by checking file size as well as existence, so the JSZip clean empty zip path is used whenever the generated requirements file has no content. - Around line 112-165: The symlink creation in zipNamedLayerRequirements is not awaited, so failures can be swallowed and the layer zip may never be created; update the async flow to await the file operation and let errors fail the build. Apply the same fix in zipRequirements as well, since it has the same un-awaited fse.symlink pattern. Use the existing zipCachePath/targetZipPath branch logic and keep the Windows copySync path unchanged. In `@packages/serverless/lib/plugins/python/lib/pip.js`: - Around line 1067-1079: The empty requirements flow is inconsistent between installRequirementsForFile and zipNamedLayerRequirements, causing an empty requirements.txt to be packaged instead of treated as “no reqs.” Update installRequirementsForFile to signal the empty-file case more explicitly (for example by returning null/undefined) or update zipNamedLayerRequirements to check the requirements file size in addition to existsSync before zipping. Make the behavior consistent using the existing symbols generateRequirementsFile, installRequirementsForFile, and zipNamedLayerRequirements so an empty layer produces a clean empty python/ artifact without requirements.txt. - Around line 1052-1065: Add an explicit guard in the Python requirements layer flow before `path.isAbsolute(requirementsFile)` is called, since `requirementsFile` may be missing or non-string when schema validation is skipped. Update the logic in `pip.js` around the `absRequirementsFile` resolution to first validate `requirementsFile` and throw a `ServerlessError` with a clear message and the existing `PYTHON_REQUIREMENTS_LAYER_REQUIREMENTS_FILE_INVALID` code, rather than allowing a native `TypeError` to escape. Use the existing `requirementsFile` and `layerName` handling in this block to keep the error consistent with the current file-existence check. --- Nitpick comments: In `@docs/sf/providers/aws/guide/python.md`: - Around line 342-358: The new Python layer example in the AWS guide breaks the existing documentation style by merging the `custom` and `functions` sections into a single YAML block. Update the example near the `pythonRequirements` and `api` configuration so it matches the surrounding “Lambda Layer” convention: keep the `custom` configuration and the `functions` configuration as separate YAML snippets while preserving the same `PydanticLambdaLayer` and `WebLambdaLayer` references. In `@packages/serverless/lib/plugins/python/index.js`: - Around line 127-132: The invalid options.layers handling in pythonRequirements should not silently delete misconfigured values; update the getter in the Python plugin to emit a warning before removing layers when it is not an object or is an array. Follow the existing validation patterns used nearby in this same getter, such as the dockerImage/dockerFile conflict and docker-related warning logic, and use this.warningLogged or this.log.warning so users know their custom.pythonRequirements.layers setting was ignored.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5ef6c132-10c6-430e-92b1-c80848a65d3e
📥 CommitsReviewing files that changed from the base of the PR and between b5ff282 and 8df2d23cbf5fce325c4fe4e11607dd005ef35993.
📒 Files selected for processing (10)
Sorry, something went wrong.
Add `custom.pythonRequirements.layers` — a named map where each entry specifies its own requirements file. For each entry the plugin: 1. Installs the explicit requirements file into a per-layer working directory via a new `installRequirementsForFile` helper in pip.js. 2. Zips the installed packages under a `python/` prefix to `.serverless/pythonRequirements-<name>.zip`. 3. Registers `service.layers[<name>]` with `package.artifact` set so the core layer compiler emits `<Name>LambdaLayer` and `<Name>LambdaLayerQualifiedArn` without further changes. Functions attach a layer with `Ref: <Name>LambdaLayer`. Invariants preserved: - The existing single-layer (`layer: true`) path is untouched. - `layer` and `layers` coexist independently. - The reserved name `pythonRequirements` and collisions with existing service layers are rejected before any install work begins. - Registration is deferred to a post-loop `Object.assign` so a mid-loop failure never leaves a half-registered state. Adds a JSON schema for `custom.pythonRequirements.layers` (via `defineCustomProperties`) and extends the function-less-service hook guard to keep hooks alive for `layers`-only services. Closes serverless#13384
Per review: installRequirementsForFile now rejects a missing/empty requirementsFile with the friendly PYTHON_REQUIREMENTS_LAYER_REQUIREMENTS_FILE_INVALID error instead of the raw TypeError path.isAbsolute throws, matching the adjacent does-not-exist check.
| Back | FazBrowse Home | New Git URL |
Summary
Key design decisions
Test plan
Closes #13384
Summary by CodeRabbit