René's URL Explorer Experiment


Title: Bug: EventBridgeV2Envelope raises UnicodeDecodeError for application/octet-stream payloads that are not UTF-8 JSON · Issue #8666 · aws-powertools/powertools-lambda-python · GitHub

Open Graph Title: Bug: EventBridgeV2Envelope raises UnicodeDecodeError for application/octet-stream payloads that are not UTF-8 JSON · Issue #8666 · aws-powertools/powertools-lambda-python

X Title: Bug: EventBridgeV2Envelope raises UnicodeDecodeError for application/octet-stream payloads that are not UTF-8 JSON · Issue #8666 · aws-powertools/powertools-lambda-python

Description: Expected Behaviour The Parser envelope handles an application/octet-stream record the same way the EventBridgeV2Event data class does: the payload is available as bytes, so a bytes model gets the raw payload, and a model the payload does...

Open Graph Description: Expected Behaviour The Parser envelope handles an application/octet-stream record the same way the EventBridgeV2Event data class does: the payload is available as bytes, so a bytes model gets the r...

X Description: Expected Behaviour The Parser envelope handles an application/octet-stream record the same way the EventBridgeV2Event data class does: the payload is available as bytes, so a bytes model gets the r...

Opengraph URL: https://github.com/aws-powertools/powertools-lambda-python/issues/8666

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: EventBridgeV2Envelope raises UnicodeDecodeError for application/octet-stream payloads that are not UTF-8 JSON","articleBody":"### Expected Behaviour\n\nThe Parser envelope handles an `application/octet-stream` record the same way the `EventBridgeV2Event` data class does: the payload is available as `bytes`, so a `bytes` model gets the raw payload, and a model the payload doesn't match raises a `ValidationError`.\n\n### Current Behaviour\n\n`EventBridgeV2Envelope.parse` (added in #8658) always runs `payload.decode()` on octet-stream bytes and passes the resulting `str` to `_parse`, which treats every `str` as JSON. Only octet-stream payloads that happen to be UTF-8 JSON work, which is the case `test_envelope_parses_octet_stream_json_bytes` covers.\n\n- Binary payloads (images, gzip, protobuf) raise a raw `UnicodeDecodeError` instead of a `ValidationError`, so handlers that catch `ValidationError` miss it.\n- Plain-text payloads fail validation even with `model=bytes`.\n\nThe data class returns the bytes for all of these, so the two APIs disagree on the same event.\n\n### Code snippet\n\n```python\nimport base64\n\nfrom pydantic import BaseModel\n\nfrom aws_lambda_powertools.utilities.data_classes import EventBridgeV2Event\nfrom aws_lambda_powertools.utilities.parser import envelopes, parse\n\n\nclass Order(BaseModel):\n    order_id: str\n\n\ndef octet_stream_event(payload: bytes) -> dict:\n    return {\n        \"Data\": base64.b64encode(payload).decode(),\n        \"Metadata\": {},\n        \"SystemMetadata\": {\"ContentType\": \"application/octet-stream\", \"aws:DeliveryType\": \"LIVE\"},\n    }\n\n\nfor payload, model in ((b\"\\xff\\xd8\\xff\\xe0JFIF\", bytes), (b\"hello world\", bytes), (b\"\\xff\\xd8\\xff\\xe0JFIF\", Order)):\n    event = octet_stream_event(payload)\n    print(f\"payload={payload!r} model={model.__name__}\")\n    print(\"  data class:\", next(iter(EventBridgeV2Event(event).records)).data)\n    try:\n        print(\"  parser    :\", parse(event=event, model=model, envelope=envelopes.EventBridgeV2Envelope))\n    except Exception as exc:\n        print(f\"  parser    : {type(exc).__module__}.{type(exc).__name__}: {str(exc).splitlines()[0]}\")\n```\n\n### Possible Solution\n\nFor octet-stream bytes, try `json.loads(payload)` and fall back to passing the raw bytes to the model when it isn't JSON (`json.loads` raises `ValueError` for both invalid UTF-8 and invalid JSON). The JSON case keeps working as today, a `bytes` model gets the raw payload, and other models raise `ValidationError`. I have this ready with tests (all parser and data class tests pass) and am happy to open the PR.\n\n### Steps to Reproduce\n\nRun the snippet above.\n\n### Powertools for AWS Lambda (Python) version\n\nlatest (develop @ 5785377)\n\n### AWS Lambda function runtime\n\n3.13\n\n### Packaging format used\n\nPyPi\n\n### Debugging logs\n\n```python\nOutput of the snippet on develop:\n\npayload=b'\\xff\\xd8\\xff\\xe0JFIF' model=bytes\n  data class: b'\\xff\\xd8\\xff\\xe0JFIF'\n  parser    : builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte\npayload=b'hello world' model=bytes\n  data class: b'hello world'\n  parser    : pydantic_core._pydantic_core.ValidationError: 1 validation error for bytes\npayload=b'\\xff\\xd8\\xff\\xe0JFIF' model=Order\n  data class: b'\\xff\\xd8\\xff\\xe0JFIF'\n  parser    : builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte\n```","author":{"url":"https://github.com/alphasafal","@type":"Person","name":"alphasafal"},"datePublished":"2026-10-25T18:54:33Z","url":"https://github.com/aws-powertools/powertools-lambda-python/issues/8666"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e6f166bc-cdc9-9aac-7c21-afd87a71ed3c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idED86:22F2F8:1235B3:1917D6:6B00822C
html-safe-nonceb5490997039dbbe68bc5de8c1f557618d07063204d4f08843f3bfcdcba4a7840
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDg2OjIyRjJGODoxMjM1QjM6MTkxN0Q2OjZCMDA4MjJDIiwidmlzaXRvcl9pZCI6IjY4MzIyMzE3MjYyNjIwMjY3OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac001ebe27f9e3a37979dc25613860c9aed5360908297b7d199151e35e97c0db27
hovercard-subject-tagissue:6028054002
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/aws-powertools/powertools-lambda-python/8666/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e8638bc000b87ad641890548018594188254c4b33d388eebeac1cab2fe53b77c/aws-powertools/powertools-lambda-python/issues/8666
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e8638bc000b87ad641890548018594188254c4b33d388eebeac1cab2fe53b77c/aws-powertools/powertools-lambda-python/issues/8666
og:image:altExpected Behaviour The Parser envelope handles an application/octet-stream record the same way the EventBridgeV2Event data class does: the payload is available as bytes, so a bytes model gets the r...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamealphasafal
hostnamegithub.com
expected-hostnamegithub.com
None82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83
turbo-cache-controlno-preview
go-importgithub.com/aws-powertools/powertools-lambda-python git https://github.com/aws-powertools/powertools-lambda-python.git
octolytics-dimension-user_id129127638
octolytics-dimension-user_loginaws-powertools
octolytics-dimension-repository_id221919379
octolytics-dimension-repository_nwoaws-powertools/powertools-lambda-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id221919379
octolytics-dimension-repository_network_root_nwoaws-powertools/powertools-lambda-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released1bc2aa1939001689f5ce935982c10a6138f745c
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/aws-powertools/powertools-lambda-python/issues/8666#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Faws-powertools%2Fpowertools-lambda-python%2Fissues%2F8666
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Faws-powertools%2Fpowertools-lambda-python%2Fissues%2F8666
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=aws-powertools%2Fpowertools-lambda-python
Reloadhttps://github.com/aws-powertools/powertools-lambda-python/issues/8666
Reloadhttps://github.com/aws-powertools/powertools-lambda-python/issues/8666
Reloadhttps://github.com/aws-powertools/powertools-lambda-python/issues/8666
aws-powertoolshttps://github.com/aws-powertools
powertools-lambda-pythonhttps://github.com/aws-powertools/powertools-lambda-python
Codehttps://github.com/aws-powertools/powertools-lambda-python
Issues40 (40)https://github.com/aws-powertools/powertools-lambda-python/issues
Pull requests20 (20)https://github.com/aws-powertools/powertools-lambda-python/pulls
Discussionshttps://github.com/aws-powertools/powertools-lambda-python/discussions
Actionshttps://github.com/aws-powertools/powertools-lambda-python/actions
Projectshttps://github.com/aws-powertools/powertools-lambda-python/projects
Security and quality1 (1)https://github.com/aws-powertools/powertools-lambda-python/security
Insightshttps://github.com/aws-powertools/powertools-lambda-python/insights
https://github.com/aws-powertools/powertools-lambda-python
New issuehttps://github.com/login?return_to=https://github.com/aws-powertools/powertools-lambda-python/issues/8666
New issuehttps://github.com/login?return_to=https://github.com/aws-powertools/powertools-lambda-python/issues/8666
#8669https://github.com/aws-powertools/powertools-lambda-python/pull/8669
Bug: EventBridgeV2Envelope raises UnicodeDecodeError for application/octet-stream payloads that are not UTF-8 JSONhttps://github.com/aws-powertools/powertools-lambda-python/issues/8666#top
#8669https://github.com/aws-powertools/powertools-lambda-python/pull/8669
https://github.com/alphasafal
bugSomething isn't workinghttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22bug%22
parserParser (Pydantic) utilityhttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22parser%22
3.38.0https://github.com/aws-powertools/powertools-lambda-python/milestone/23
https://github.com/alphasafal
alphasafalhttps://github.com/alphasafal
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#issue-6028054002
#8658https://github.com/aws-powertools/powertools-lambda-python/pull/8658
5785377https://github.com/aws-powertools/powertools-lambda-python/commit/57853775090ffe9a9995022372e8651ea0cdcb18
alphasafalhttps://github.com/alphasafal
bugSomething isn't workinghttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22bug%22
triagePending triage from maintainershttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22triage%22
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34198126074
github-project-automationhttps://github.com/apps/github-project-automation
Powertools for AWS Lambda (Python)https://github.com/orgs/aws-powertools/projects/3
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34198127677
github-project-automationhttps://github.com/apps/github-project-automation
Powertools for AWS Lambda (Python)https://github.com/orgs/aws-powertools/projects/3
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666
https://github.com/leandrodamascena
leandrodamascenahttps://github.com/leandrodamascena
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#issuecomment-6401914661
@alphasafalhttps://github.com/alphasafal
#8658https://github.com/aws-powertools/powertools-lambda-python/pull/8658
leandrodamascenahttps://github.com/leandrodamascena
parserParser (Pydantic) utilityhttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22parser%22
triagePending triage from maintainershttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22triage%22
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34198763960
leandrodamascenahttps://github.com/leandrodamascena
alphasafalhttps://github.com/alphasafal
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34198764244
leandrodamascenahttps://github.com/leandrodamascena
3.38.0https://github.com/aws-powertools/powertools-lambda-python/milestone/23
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34198764839
alphasafalhttps://github.com/alphasafal
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34199216141
fix(parser): pass non-JSON octet-stream payloads to the model in Even…https://github.com/alphasafal/powertools-lambda-python/commit/c46af8c2f6dd7a7afdc0d40d5ce5025ef9f4b286
https://docs.github.com/articles/closing-issues-via-commit-messages
c46af8chttps://github.com/alphasafal/powertools-lambda-python/commit/c46af8c2f6dd7a7afdc0d40d5ce5025ef9f4b286
https://github.com/alphasafal
alphasafalhttps://github.com/alphasafal
on Oct 25, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#issuecomment-6402084431
@leandrodamascenahttps://github.com/leandrodamascena
#8669https://github.com/aws-powertools/powertools-lambda-python/pull/8669
leandrodamascenahttps://github.com/leandrodamascena
completedhttps://github.com/aws-powertools/powertools-lambda-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#8669https://github.com/aws-powertools/powertools-lambda-python/pull/8669
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34460542866
github-project-automationhttps://github.com/apps/github-project-automation
Powertools for AWS Lambda (Python)https://github.com/orgs/aws-powertools/projects/3
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666
https://github.com/apps/powertools-for-aws-oss-automation
powertools-for-aws-oss-automationhttps://github.com/apps/powertools-for-aws-oss-automation
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#issuecomment-6465964627
Powertools for AWS - OSS Automationhttps://github.com/aws-powertools/powertools-lambda-oss-automation
powertools-for-aws-oss-automationhttps://github.com/apps/powertools-for-aws-oss-automation
pending-releaseFix or implementation already in dev waiting to be releasedhttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22pending-release%22
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34460567068
alphasafalhttps://github.com/alphasafal
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34462516851
fix(parser): pass non-JSON octet-stream payloads to the model in Even…https://github.com/alphasafal/powertools-lambda-python/commit/08f63b118b763cfe5eedc6e372e8c31233706832
https://docs.github.com/articles/closing-issues-via-commit-messages
08f63b1https://github.com/alphasafal/powertools-lambda-python/commit/08f63b118b763cfe5eedc6e372e8c31233706832
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#issuecomment-6467483791
GitHub Actionshttps://help.github.com/en/actions
3.38.0https://github.com/aws-powertools/powertools-lambda-python/releases/tag/v3.38.0
github-actionshttps://github.com/apps/github-actions
pending-releaseFix or implementation already in dev waiting to be releasedhttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22pending-release%22
on Oct 28, 2026https://github.com/aws-powertools/powertools-lambda-python/issues/8666#event-34466836770
Sign up for freehttps://github.com/signup?return_to=https://github.com/aws-powertools/powertools-lambda-python/issues/8666
Sign in to commenthttps://github.com/login?return_to=https://github.com/aws-powertools/powertools-lambda-python/issues/8666
alphasafalhttps://github.com/alphasafal
bugSomething isn't workinghttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22bug%22
parserParser (Pydantic) utilityhttps://github.com/aws-powertools/powertools-lambda-python/issues?q=state%3Aopen%20label%3A%22parser%22
Powertools for AWS Lambda (Python)https://github.com/orgs/aws-powertools/projects/3
3.38.0https://github.com/aws-powertools/powertools-lambda-python/milestone/23
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.