Skip to content

fix: TypeError in invite_user_v1 due to schema mismatch#1418

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/dalgo-backend-2fb-serialization
Open

fix: TypeError in invite_user_v1 due to schema mismatch#1418
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/dalgo-backend-2fb-serialization

Conversation

@sentry

@sentry sentry Bot commented Jun 23, 2026

Copy link
Copy Markdown

This PR addresses issue DALGO-BACKEND-2FB, a TypeError: Object of type DjangoGetter is not JSON serializable occurring at the /api/v1/organizations/users/invite/ endpoint.

Root Cause:
When an invitation was resent, the invite_user_v1 function in ddpui/core/orguserfunctions.py returned an InvitationSchema object (generated by from_invitation(invitation)) that was missing the invited_role_uuid field. This field is required by the API's declared response schema (NewInvitationSchema), leading to a PydanticValidationError. Subsequently, when the system attempted to serialize this validation error for the API response, the exc.errors() object contained DjangoGetter instances, which are not JSON serializable, resulting in the observed TypeError.

Changes Made:

  1. Corrected Response Schema (ddpui/core/orguserfunctions.py): Modified the invite_user_v1 function to explicitly construct and return a NewInvitationSchema object with the invited_email and invited_role_uuid (from invitation.invited_new_role.uuid) when an invitation is resent. This ensures the returned data conforms to the expected schema.
  2. Robust Error Serialization (ddpui/routes.py): Added a try-except TypeError block within the pydantic_validation_error_handler. If exc.errors() contains non-serializable objects, the handler will now gracefully convert the entire error detail to a string, preventing the TypeError and ensuring a valid JSON response.

Fixes DALGO-BACKEND-2FB

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.26%. Comparing base (11a5843) to head (93be07e).

Files with missing lines Patch % Lines
ddpui/core/orguserfunctions.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1418   +/-   ##
=======================================
  Coverage   60.26%   60.26%           
=======================================
  Files         146      146           
  Lines       17222    17222           
=======================================
  Hits        10378    10378           
  Misses       6844     6844           

☔ 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.

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.

0 participants