Skip to content

fix: handle Decimal serialization in attached_clients response#272

Merged
layertwo merged 3 commits intomainlinefrom
fix/decimal-json-serialization-attached-clients
Mar 4, 2026
Merged

fix: handle Decimal serialization in attached_clients response#272
layertwo merged 3 commits intomainlinefrom
fix/decimal-json-serialization-attached-clients

Conversation

@layertwo
Copy link
Owner

@layertwo layertwo commented Mar 4, 2026

Summary

  • DynamoDB returns numeric fields (createdAt, lastAccessTime) as Decimal objects, causing TypeError: Object of type Decimal is not JSON serializable in device-related endpoints
  • Replaced json.dumps with the existing json_dumps utility (src/shared/utils.py) which uses DecimalEncoder to convert Decimalfloat
  • Affected routes:
    • GET /v1/account/attached_clients
    • GET /v1/account/devices
    • POST /v1/account/device

Test plan

  • All 1002 existing tests pass with 100% coverage
  • Verify the three affected endpoints no longer raise TypeError for users with devices that have numeric timestamp fields

DynamoDB returns numeric fields (createdAt, lastAccessTime) as Decimal
objects, which the standard json.dumps cannot serialize. Swap to the
existing json_dumps utility which uses DecimalEncoder to convert Decimals
to floats.
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  lambda/src/routes/auth
  account_attached_clients.py
  account_device.py
  account_devices.py
Project Total  

This report was generated by python-coverage-comment-action

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Diff for stage: DefaultStage

Diff for stack: GitHubOidcStack - 0 to add, 1 to update, 0 to destroy 🟡

Details
Resources
[~] Custom::AWSCDKOpenIdConnectProvider GitHubOidcProvider7EBF861F
 ├─ [~] CodeHash
 │   ├─ [-] 62fa02efcaa700e1c247e1d3cc2aa0cd07a0808a9a3e3d2230e51f57a02233fb
 │   └─ [+] d75c48c9f82cde63e9bf414df335e84e8ac24f11eb34889be255b702aec71e50
 └─ [~] RejectUnauthorized
[~] AWS::Lambda::Function CustomAWSCDKOpenIdConnectProviderCustomResourceProviderHandlerF2C543E0
 ├─ [~] Code
 │   └─ [~] .S3Key:
 │       ├─ [-] 62fa02efcaa700e1c247e1d3cc2aa0cd07a0808a9a3e3d2230e51f57a02233fb.zip
 │       └─ [+] d75c48c9f82cde63e9bf414df335e84e8ac24f11eb34889be255b702aec71e50.zip
 └─ [~] Metadata
     └─ [~] .aws:asset:path:
         ├─ [-] asset.62fa02efcaa700e1c247e1d3cc2aa0cd07a0808a9a3e3d2230e51f57a02233fb
         └─ [+] asset.d75c48c9f82cde63e9bf414df335e84e8ac24f11eb34889be255b702aec71e50

Diff for stack: Service-prod - 0 to add, 0 to update, 0 to destroy

Details
Resources
[~] AWS::Lambda::Function AuthApiHandlerED50ACFA
 ├─ [~] Code
 │   └─ [~] .S3Key:
 │       ├─ [-] 6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7.zip
 │       └─ [+] d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21.zip
 └─ [~] Metadata
     └─ [~] .aws:asset:path:
         ├─ [-] asset.6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7
         └─ [+] asset.d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21
[~] AWS::Lambda::Function TokenApiHandler2E66DB25
 ├─ [~] Code
 │   └─ [~] .S3Key:
 │       ├─ [-] 6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7.zip
 │       └─ [+] d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21.zip
 └─ [~] Metadata
     └─ [~] .aws:asset:path:
         ├─ [-] asset.6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7
         └─ [+] asset.d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21
[~] AWS::Lambda::Function ProfileApiHandler9B65A298
 ├─ [~] Code
 │   └─ [~] .S3Key:
 │       ├─ [-] 6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7.zip
 │       └─ [+] d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21.zip
 └─ [~] Metadata
     └─ [~] .aws:asset:path:
         ├─ [-] asset.6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7
         └─ [+] asset.d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21
[~] AWS::Lambda::Function ApiHandler5E7490E8
 ├─ [~] Code
 │   └─ [~] .S3Key:
 │       ├─ [-] 6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7.zip
 │       └─ [+] d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21.zip
 └─ [~] Metadata
     └─ [~] .aws:asset:path:
         ├─ [-] asset.6e7b68b5b107e56522cc306a58423e59ffdea3918ca8c745c847f831592141b7
         └─ [+] asset.d5dda210abc5cad8d04de1baa1e4c3c74c22dfd51aef2a701cbb3664c3dd2c21
[~] AWS::Lambda::Function ChannelApiHandler02759D57
 ├─ [~] Code
 │   └─ [~] .S3Key:
 │       ├─ [-] 95e5fb7e938ee8469f2d4ae8d4257ceb5aec48be1b04194dcb20388b05e968f1.zip
 │       └─ [+] 36bc2aabcf396fa8cb5642aea04457f0ab6d238f94b2608c8da56d03044b4b0b.zip
 └─ [~] Metadata
     └─ [~] .aws:asset:path:
         ├─ [-] asset.95e5fb7e938ee8469f2d4ae8d4257ceb5aec48be1b04194dcb20388b05e968f1
         └─ [+] asset.36bc2aabcf396fa8cb5642aea04457f0ab6d238f94b2608c8da56d03044b4b0b

No Changes for stack: Frontend-prod ✅
No Changes for stack: Monitoring-prod ✅

Generated for commit 557f269 at 2026-03-04T03:07:04.898Z

layertwo added 2 commits March 3, 2026 19:01
Same Decimal serialization issue as account_attached_clients: both routes
serialize DynamoDB data that may contain Decimal values for createdAt and
lastAccessTime fields.
@layertwo layertwo merged commit 4f3c166 into mainline Mar 4, 2026
10 checks passed
@layertwo layertwo deleted the fix/decimal-json-serialization-attached-clients branch March 4, 2026 03:07
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.

1 participant