Skip to content

test(shared): compare abs_lambda_path against a normalised path - #8457

Merged
leandrodamascena merged 4 commits into
aws-powertools:developfrom
MohammedAlkindi:fix/abs-lambda-path-posix
Sep 14, 2026
Merged

leandrodamascena merged 4 commits into
aws-powertools:developfrom
MohammedAlkindi:fix/abs-lambda-path-posix

Conversation

@MohammedAlkindi

@MohammedAlkindi MohammedAlkindi commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Issue number: closes #8449

test_abs_lambda_path_empty_envvar compared abs_lambda_path() against a hardcoded /var/task, which only holds on Linux, so the test failed on a Windows checkout.

Changes The assertion now compares against str(Path(default_lambda_path)), so it normalises to whatever separators the function returns on the platform running the suite. Runtime code is unchanged: as @leandrodamascena notes, Lambda runs on Linux and abs_lambda_path should keep returning native paths.

User experience No change. The fix is test-only.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

abs_lambda_path joined LAMBDA_TASK_ROOT with pathlib.Path, which is WindowsPath
off Linux, so str(Path("/var/task", "")) returned "\var\task". The docstring
promises the environment variable is used as given, and the repo's own
test_abs_lambda_path_empty_envvar fails on an unmodified Windows checkout. CI is
ubuntu-latest only, so it never surfaced there.

The Lambda runtime is always Linux, so use PurePosixPath when LAMBDA_TASK_ROOT is
set and keep the existing Path behaviour for the unset local case. Behaviour on
Linux is unchanged.

test_abs_lambda_path_w_filename_envvar built its expected value with the same
platform-dependent Path call, so it passed either way and masked the bug; it now
asserts the POSIX result directly.
@MohammedAlkindi
MohammedAlkindi requested a review from a team as a code owner September 14, 2026 13:10
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 14, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 14, 2026

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @MohammedAlkindi . Lambda runs on Linux, so forcing POSIX paths in the runtime code does not make sense. The problem was only the test hardcoding a Linux path.

I pushed a change to keep the runtime code as it was and fix only the test.

Please add the acknowledgment section back. The check is failing, and I cannot merge the PR without it.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.65%. Comparing base (4810265) to head (0d90622).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8457   +/-   ##
========================================
  Coverage    96.65%   96.65%           
========================================
  Files          296      296           
  Lines        14885    14885           
  Branches      1263     1263           
========================================
  Hits         14387    14387           
  Misses         363      363           
  Partials       135      135           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MohammedAlkindi MohammedAlkindi changed the title fix(shared): keep LAMBDA_TASK_ROOT POSIX-shaped off Linux test(shared): compare abs_lambda_path against a normalised path Sep 14, 2026
@mergify

mergify Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@sonarqubecloud

Copy link
Copy Markdown

@leandrodamascena
leandrodamascena merged commit de4af6b into aws-powertools:develop Sep 14, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commons size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

abs_lambda_path returns native separators on Windows, failing its own unit test

2 participants