fix: DCI envelope support for disability registry search (#217)#303
fix: DCI envelope support for disability registry search (#217)#303Tarekchehahde wants to merge 1 commit into
Conversation
…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>
There was a problem hiding this comment.
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.
| 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), | ||
| ) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Summary
/sync/searchstub endpoints to acceptDCIEnvelope(matching client integrations and/registry/sync/search).on-searchenvelope with onesearch_responseitem per request item (multi-item batch no longer fails validation).Test plan
./spp test spp_dci_server—TestRegistryAliasStubs.test_search_stubs_return_per_item_rjct/disability/registry/sync/searchreturns 200 + per-itemrjct(until disability module ships)Fixes #217
Made with Cursor