Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Denote webhook event payload.object.href as a not required property #151

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

oliverlambson
Copy link
Contributor

@oliverlambson oliverlambson commented Jan 24, 2025

In audit_log.created events, payload.object does not have an href property.


Library: onfido-python
Version: 4.6.0

Received webhook body:

{
    "payload": {
        "resource_type": "audit_log",
        "action": "audit_log.created",
        "object": {
            "id": "...",
            "activity": "view_workflow_run",
            "category": "workflow_results",
            "created_at_iso8601": "2025-01-24T19:07:33Z",
            "user": {
                "email": "[email protected]",
                "full_name": "Oliver Lambson",
                "ip_address": "..."
            }
        }
    }
}
from onfido.models import WebhookEvent

WebhookEvent.from_json(raw_event)
Traceback (most recent call last):
  File ...
  File "/karoo/.venv/lib/python3.13/site-packages/onfido/webhook_event_verifier.py", line 27, in read_payload
    return WebhookEvent.from_json(raw_event)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/karoo/.venv/lib/python3.13/site-packages/onfido/models/webhook_event.py", line 53, in from_json
    return cls.from_dict(json.loads(json_str))
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/karoo/.venv/lib/python3.13/site-packages/onfido/models/webhook_event.py", line 95, in from_dict
    "payload": WebhookEventPayload.from_dict(obj["payload"]) if obj.get("payload") is not None else None
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/karoo/.venv/lib/python3.13/site-packages/onfido/models/webhook_event_payload.py", line 106, in from_dict
    "object": WebhookEventPayloadObject.from_dict(obj["object"]) if obj.get("object") is not None else None,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/karoo/.venv/lib/python3.13/site-packages/onfido/models/webhook_event_payload_object.py", line 96, in from_dict
    _obj = cls.model_validate({
        "id": obj.get("id"),
    ...<3 lines>...
        "href": obj.get("href")
    })
  File "/karoo/.venv/lib/python3.13/site-packages/pydantic/main.py", line 627, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        obj, strict=strict, from_attributes=from_attributes, context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
pydantic_core._pydantic_core.ValidationError: 1 validation error for WebhookEventPayloadObject
href
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.10/v/string_type

@oliverlambson oliverlambson marked this pull request as draft January 24, 2025 19:17
In audit_log.created events, payload.object does not have an href
property
@oliverlambson oliverlambson marked this pull request as ready for review January 24, 2025 19:27
@oliverlambson
Copy link
Contributor Author

@dvacca-onfido another one, this time using the latest client library, so i think this is a real bug

Copy link
Contributor

@dvacca-onfido dvacca-onfido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliverlambson LGTM, thanks for your contribution. Indeed href is missing for this kind of webhook event.

@dvacca-onfido dvacca-onfido changed the title Webhook event payload.object.href is not a required property Denote webhook event payload.object.href as a not required property Jan 27, 2025
@dvacca-onfido dvacca-onfido merged commit e280645 into onfido:master Jan 27, 2025
4 checks passed
@oliverlambson
Copy link
Contributor Author

@dvacca-onfido thanks!

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.

2 participants