Fix ImportError with slash-delimited Lambda handler paths#3894
Merged
xrmx merged 4 commits intoOct 30, 2025
Conversation
AWS Lambda accepts handler paths in both formats: - Slash-delimited: python/functions/api.handler - Dot-delimited: python.functions.api.handler The instrumentation was failing when slash-delimited paths were used because it attempted to import invalid Python module paths containing forward slashes. This fix normalizes the handler path by converting slashes to dots before splitting the module and function names. Fixes open-telemetry#1465
- Add changelog entry in Unreleased section - Add unit test verifying both slash and dot-delimited handler paths work - Test confirms instrumentation handles both formats correctly Related to open-telemetry#1465
|
|
tammy-baylis-swi
approved these changes
Oct 28, 2025
tammy-baylis-swi
left a comment
Contributor
There was a problem hiding this comment.
Thank you for this! It lgtm, the Maintainers will also have a look.
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
emdneto
approved these changes
Oct 28, 2025
xrmx
approved these changes
Oct 30, 2025
bisgaard-itis
pushed a commit
to bisgaard-itis/opentelemetry-python-contrib
that referenced
this pull request
Nov 3, 2025
…etry#3894) * Fix ImportError with slash-delimited Lambda handler paths AWS Lambda accepts handler paths in both formats: - Slash-delimited: python/functions/api.handler - Dot-delimited: python.functions.api.handler The instrumentation was failing when slash-delimited paths were used because it attempted to import invalid Python module paths containing forward slashes. This fix normalizes the handler path by converting slashes to dots before splitting the module and function names. Fixes open-telemetry#1465 * Add changelog and unit test for slash-delimited handler fix - Add changelog entry in Unreleased section - Add unit test verifying both slash and dot-delimited handler paths work - Test confirms instrumentation handles both formats correctly Related to open-telemetry#1465 * Update CHANGELOG.md Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> --------- Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
sightseeker
added a commit
to sightseeker/opentelemetry-python-contrib
that referenced
this pull request
Mar 11, 2026
…etry#3894) * Fix ImportError with slash-delimited Lambda handler paths AWS Lambda accepts handler paths in both formats: - Slash-delimited: python/functions/api.handler - Dot-delimited: python.functions.api.handler The instrumentation was failing when slash-delimited paths were used because it attempted to import invalid Python module paths containing forward slashes. This fix normalizes the handler path by converting slashes to dots before splitting the module and function names. Fixes open-telemetry#1465 * Add changelog and unit test for slash-delimited handler fix - Add changelog entry in Unreleased section - Add unit test verifying both slash and dot-delimited handler paths work - Test confirms instrumentation handles both formats correctly Related to open-telemetry#1465 * Update CHANGELOG.md Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> --------- Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
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.
Description
AWS Lambda accepts handler paths in both formats:
python/functions/api.handlerpython.functions.api.handlerThe instrumentation was failing when slash-delimited paths were used because it attempted to import invalid Python module paths containing forward slashes. This fix normalizes the handler path by converting slashes to dots before splitting the module and function names.
Fixes #1465
Type of change
How Has This Been Tested?
test_slash_delimited_handler_path()that verifies both slash-delimited and dot-delimited handler paths work correctlypython/functions/api.handler) in production environmentImportError: No module named 'python/functions/api', now works correctlyDoes This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.