Skip to content

PGR complaint create fails (JSONPATH_ERROR) when ServiceDefs are seeded only at the city, not the state root #54

Description

@KDwevedi

Symptom

A citizen filing a complaint of an onboarded type (e.g. colecta_lixo on mz.maputo) gets:

{"Errors":[{"code":"JSONPATH_ERROR","message":"Failed to parse mdms response for service: colecta_lixo"}]}

…even though the complaint type shows in the UI dropdown. So complaints can't be filed.

Root cause

pgr-services resolves RAINMAKER-PGR.ServiceDefs at the computed state root of the complaint's tenant (mz.maputomz) via mdms-v2/v1/_search. But the configurator / onboarding writes the city's complaint types only at the city tenant (mz.maputo). The state root (mz) has only the bootstrap defaults, so the lookup returns nothing → JSONPATH_ERROR. The UI dropdown reads the city, which is why it offers a type the backend can't validate.

This is independent of STATE_LEVEL_TENANT_ID — pgr derives the read tenant from the complaint's tenantId at request time (confirmed: changing that env did not help; replicating the defs to the state root did).

Repro

  1. Onboard a city (e.g. mz.maputo) with custom complaint types via the configurator.
  2. As a citizen, file a complaint of a custom type.
  3. JSONPATH_ERROR: Failed to parse mdms response for service: <code>.

Manual workaround

Replicate the city's ServiceDefs up to the state root and bust the mdms cache:

INSERT INTO eg_mdms_data (id, tenantid, uniqueidentifier, schemacode, data, isactive, createdby, lastmodifiedby, createdtime, lastmodifiedtime)
SELECT gen_random_uuid()::text, '<state>', uniqueidentifier, schemacode, data, isactive, createdby, lastmodifiedby, createdtime, lastmodifiedtime
FROM eg_mdms_data WHERE schemacode='RAINMAKER-PGR.ServiceDefs' AND tenantid='<state>.<city>'
ON CONFLICT DO NOTHING;

then docker restart egov-mdms-service.

Fix

Onboarding should seed RAINMAKER-PGR.ServiceDefs at the state root (where pgr validates) in addition to the city (where the UI lists them) — either the configurator's complaint-type phase writes to both, or a post-onboarding replication/sync step. They must stay in sync.

Regression test

Covered by local-setup/tests/test_onboarding_regressions.py::test_servicedefs_resolve_at_state_root (+ opt-in test_complaint_create_passes_servicedef_validation).

Found during the Maputo (mz.maputo) bring-up, 2026-05-21.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions