Skip to content

Fix layer path resolution#209

Merged
GrahamCampbell merged 1 commit intomainfrom
fix/layer-path-service-dir
Apr 29, 2026
Merged

Fix layer path resolution#209
GrahamCampbell merged 1 commit intomainfrom
fix/layer-path-service-dir

Conversation

@GrahamCampbell
Copy link
Copy Markdown
Contributor

@GrahamCampbell GrahamCampbell commented Apr 29, 2026

Resolves layer package paths relative to serverless.serviceDir instead of process.cwd().

This cwd dependency was introduced in 3093c83 when layer packaging started pre-resolving layerObject.path with path.resolve(...) to support paths like ./layer and trailing slash variants. That made packaging sensitive to the shell cwd whenever cwd !== serviceDir.

The fix anchors the layer path once with serverless.serviceDir and uses that same path for both file resolution and ZIP prefix stripping.

Adds a regression test for packageLayer() with a different current working directory.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes layer packaging path resolution so layer file paths are resolved relative to serverless.serviceDir (service root) rather than process.cwd(), and adds a regression test to ensure correctness when the current working directory differs from the service directory.

Changes:

  • Resolve layerObject.path against serverless.serviceDir in packageLayer() and use that resolved path consistently for zipping inputs/prefix.
  • Add a unit test that changes process.cwd() to validate packageLayer() still resolves layer files relative to serviceDir.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/plugins/package/lib/package-service.js Adjusts packageLayer() to compute an absolute layerPath from serviceDir and use it for file path construction and zip prefixing.
test/unit/lib/plugins/package/lib/package-service.test.js Adds regression coverage ensuring layer packaging is independent of process.cwd().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GrahamCampbell GrahamCampbell merged commit dba8087 into main Apr 29, 2026
8 checks passed
@GrahamCampbell GrahamCampbell deleted the fix/layer-path-service-dir branch April 29, 2026 23:13
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.

2 participants