Skip to content

fix: DCI envelope support for disability registry search (#217)#303

Open
Tarekchehahde wants to merge 1 commit into
OpenSPP:19.0from
Tarekchehahde:fix/217-disability-dci-envelope-search
Open

fix: DCI envelope support for disability registry search (#217)#303
Tarekchehahde wants to merge 1 commit into
OpenSPP:19.0from
Tarekchehahde:fix/217-disability-dci-envelope-search

Conversation

@Tarekchehahde

Copy link
Copy Markdown

Summary

  • Change disability/crvs/farmer /sync/search stub endpoints to accept DCIEnvelope (matching client integrations and /registry/sync/search).
  • Return a DCI on-search envelope with one search_response item per request item (multi-item batch no longer fails validation).
  • Update registry alias tests to use envelope payloads with 2 search items.

Test plan

  • ./spp test spp_dci_serverTestRegistryAliasStubs.test_search_stubs_return_per_item_rjct
  • POST multi-item DCI envelope to /disability/registry/sync/search returns 200 + per-item rjct (until disability module ships)

Fixes #217

Made with Cursor

…enSPP#217)

Disability/crvs/farmer sync/search stubs now accept DCIEnvelope requests
and return per-item on-search envelopes, fixing multi-item batch handling.

Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the sync search endpoints for the Disability, Civil, and Farmer registries to accept and return DCIEnvelope wrappers, introducing a helper function _build_stub_search_envelope to generate unimplemented stub responses. It also updates the corresponding tests and replaces deprecated utcnow() calls with timezone-aware now(UTC). Feedback includes a recommendation to use the existing build_signed_envelope helper to reduce boilerplate and ensure proper signing, as well as a correction for an incorrect path in the disability_sync_notify docstring.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +73 to +94
our_sender_id = get_sender_id(env) or "openspp"
total_count = len(response_items)

callback_header = DCICallbackHeader(
version=request_envelope.header.version,
message_id=str(uuid.uuid4()),
message_ts=datetime.now(UTC),
action=f"on-{request_envelope.header.action}",
sender_id=our_sender_id,
receiver_id=request_envelope.header.sender_id,
total_count=total_count,
status="rjct",
status_reason_code=MsgHeaderStatusReasonCode.ACTION_NOT_SUPPORTED.value,
status_reason_message=not_implemented_message,
completed_count=0,
)

return DCIEnvelope(
signature="",
header=callback_header,
message=search_response.model_dump(mode="json", exclude_none=True),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Instead of manually constructing the DCICallbackHeader and returning an unsigned DCIEnvelope (with signature=""), you can leverage the existing build_signed_envelope helper from spp_dci.services.response_helpers. This reduces boilerplate, ensures consistency, and automatically signs the envelope if a signing key is configured in the environment.

    from odoo.addons.spp_dci.services.response_helpers import build_signed_envelope

    return build_signed_envelope(
        env=env,
        original_header=request_envelope.header,
        response_message=search_response.model_dump(mode="json", exclude_none=True),
        status_code="rjct",
        status_reason_code=MsgHeaderStatusReasonCode.ACTION_NOT_SUPPORTED.value,
        status_reason_message=not_implemented_message,
        completed_count=0,
    )

SPDCI-compliant Disability Registry notification endpoint.

Path: /disability/registry/sync/notify
Path: /disability/registry/sync/search

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The path in the docstring was incorrectly changed to /disability/registry/sync/search. Since this is the notification endpoint (disability_sync_notify), it should remain /disability/registry/sync/notify.

Suggested change
Path: /disability/registry/sync/search
Path: /disability/registry/sync/notify

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.

Disability DCI sync search returns HTTP 500 for multi-item search_request

1 participant