fix: add PolicyMfaFactors model to policy unions - #153
Open
Meldiron wants to merge 1 commit into
Open
Conversation
Appwrite Cloud now returns an mfa-factors policy from GET /v1/project/policies, but the SDK's PolicyList and get_policy unions predate it, so pydantic fails with "Unable to parse response into PolicyList: 23 validation errors" for any project.list_policies() call against Cloud. Add the PolicyMfaFactors model (totp/email/phone/custom, mirroring the server's PolicyMFAFactors response model), include it in the PolicyList and get_policy unions and the get_policy dispatch, and add MFA_FACTORS to the ProjectPolicyId enum. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Too many files changed for review (355 files, 200 file limit). Bypass the limit by tagging |
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.
What does this PR do?
Appwrite Cloud now returns an
mfa-factorspolicy fromGET /v1/project/policies(server modelPolicyMFAFactors, added in appwrite/appwrite), but this SDK's unions predate it. As a result, everyproject.list_policies()call against Cloud currently crashes with:(caught by the Connect snippets QA in appwrite/vibes — all four python lanes fail; other SDKs parse leniently and are unaffected)
Changes, mirroring the generated style:
appwrite/models/policy_mfa_factors.py—PolicyMfaFactorswithtotp/email/phone/custombooleans, matching the server'sPolicyMFAFactorsresponse model.PolicyList.policiesunion and exported fromappwrite.models.get_policyreturn union, docstring, and$iddispatch inservices/project.py.MFA_FACTORS = "mfa-factors"to theProjectPolicyIdenum.Not included: the
update_mfa_factors_policy()service method (PATCH /v1/project/policies/mfa-factors) — the next spec regeneration will add it; this PR is the minimal fix for the parsing crash. If a regen is imminent, feel free to close this in favor of it — the vibes QA temporarily installs from this branch until a release containing the fix is on PyPI.Test plan
parses successfully, with item 2 typed as
PolicyMfaFactors;model_dump(by_alias=True)round-trips. Existing policy types still parse.🤖 Generated with Claude Code