Conversation
The built-in python plugin's runtime check returned false at the service level when no functions were defined, causing before/after hooks to be skipped. As a result, services configured with custom.pythonRequirements.layer and no functions: block produced no PythonRequirementsLambdaLayer resource or related CFN outputs. - Treat a python provider runtime + custom.pythonRequirements.layer as a valid trigger for the service-level hooks. - Run the shared requirements install when there are no python functions but a layer is configured, so layerRequirements() finds a populated .serverless/requirements directory to zip. - Add an integration fixture and test asserting the layer resource and outputs are generated for a layer-only service.
✅ 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. |
📝 WalkthroughWalkthroughThis PR extends Python plugin support to recognize and properly package "layer-only" services—those configured with ChangesPython Layer-Only Service Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1a2eb49. Configure here.
Summary
The built-in
pythonplugin skipped the lambda layer build for services that declaredcustom.pythonRequirements.layerbut had nofunctions:block. The service-level runtime guard returnedfalsewhen no python functions and no python agents were present, so thebefore/afterhooks (which install requirements and calllayerRequirements()) never ran. Result: noPythonRequirementsLambdaLayerresource and noPythonRequirementsLambdaLayerQualifiedArn/Hash/S3Keyoutputs in the generated CloudFormation template.This restores parity with the standalone
serverless-python-requirementsplugin's behaviour for layer-only services.Changes
isFunctionRuntimePythonnow also returnstruefor service-level hooks whencustom.pythonRequirements.layeris truthy and the provider runtime starts withpython. The runtime gate is preserved so non-python services with stalepythonRequirementsconfig remain unaffected.installAllRequirementsruns the shared install step when the service is layer-only (no python functions andoptions.layerset), solayerRequirements()has a populated.serverless/requirements.txtto zip.tests/python/tests/layer_only/and a test intests/python/test.jsthat asserts the layer resource, layer outputs, and packaged dependency are present.Behaviour notes
serverless packagewill now actually invoke pip. If the local environment lacks thepythonX.Ybinary matching the configured runtime, packaging will fail loudly. SetpythonBinor usedockerizePipto resolve.Test plan
tests/python/tests/layer_onlytest passes.tests/pythonsuite unchanged.custom.pythonRequirements.layer: true, nofunctions:) now producesPythonRequirementsLambdaLayerand the three layer outputs.plugins: [serverless-python-requirements]continues to work unchanged (built-in is overridden).Summary by CodeRabbit
New Features
Tests
Note
Medium Risk
Moderate risk: changes the runtime gating so the Python packaging hooks now run for services with
custom.pythonRequirements.layereven whenfunctionsis empty, which can newly invokepipduringsls packageand fail in misconfigured environments.Overview
Fixes the built-in Python requirements plugin so layer-only services (configured with
custom.pythonRequirements.layerbut nofunctions) still run the packaging hooks and generatePythonRequirementsLambdaLayeroutputs.Updates the requirements installer to perform the shared install step for these layer-only services, ensuring
.serverless/requirementsis populated before zipping. Adds an integration test fixture (tests/python/tests/layer_only) verifying the CloudFormation layer resource/outputs and that dependencies are present in.serverless/pythonRequirements.zip.Reviewed by Cursor Bugbot for commit 1a2eb49. Bugbot is set up for automated code reviews on this repo. Configure here.