Skip to content

[Prod] Gender data missing in personnel endpoint  #2778

Description

@arunissun

Issue

The GO personnel endpoint is returning blank/null values for the gender field, even though gender/sex data exists in the underlying Molnix/RRMS deployment detail payload.

Endpoint affected:

https://goadmin.ifrc.org/api/v2/personnel/

The issue appears to be in the Molnix sync code. The sync reads gender from:

md["person"]["sex"]

but md usually comes from the deployment list payload returned by molnix.get_deployments(). That list payload includes basic person fields such as fullname, but usually does not include sex.

The full deployment detail endpoint does include person.sex, but the current code only fetches full deployment detail when position_id is missing. Since most deployment list records already have position_id, the detail fetch is skipped and personnel.gender is saved as None.

Incorrect code pattern:

if "position_id" not in md:
    md2 = molnix_api.get_deployment(md["id"])
    md |= md2["deployment"]

gender = None
try:
    if md["person"] and "sex" in md["person"]:
        gender = md["person"]["sex"]
except Exception:
    warning = "Did not find gender info in %d" % md["id"]
    logger.warning(warning)
    warnings.append(warning)
    continue

Suggested correction:

person = md.get("person") or {}

# The deployment list payload usually has person.fullname but not person.sex.
# Fetch full deployment detail when person.sex is missing.
if "position_id" not in md or "sex" not in person:
    md2 = molnix_api.get_deployment(md["id"])
    md.update(md2.get("deployment") or {})

person = md.get("person") or {}
gender = person.get("sex") or None

Then continue to save:

personnel.gender = gender

Also recommended:

personnel.name = person.get("fullname")

instead of:

personnel.name = md["person"]["fullname"]

Missing gender should not skip the whole personnel record. The record should still be saved with gender = None.

Steps to reproduce

  1. Call the GO personnel endpoint:
GET https://goadmin.ifrc.org/api/v2/personnel/
  1. Inspect returned personnel records.

  2. Observe that the gender field is blank/null across records.

  3. Compare against Molnix/RRMS deployment detail for a personnel record’s molnix_id:

GET /api/api/deployments/{personnel.molnix_id}
  1. The detailed deployment payload includes:
deployment.person.sex
  1. The deployment list payload used by the sync generally does not include person.sex.

Expected behaviour

The GO personnel.gender field should be populated from Molnix/RRMS:

deployment.person.sex

when that value exists.

If person.sex is missing or blank, the personnel record should still be imported, with gender = null.

Related feature

Molnix/RRMS sync into GO personnel records.

Relevant area:

sync_molnix
sync_deployments()
Personnel.gender
/api/v2/personnel/

Impact

This affects users consuming the GO personnel endpoint, especially the new and old Surge Dashboard

It affects Power BI reporting and any analysis based on:

/api/v2/personnel/

Severity

Functional reporting impact.

The personnel records are imported, but gender-based analysis is incomplete or impossible from the GO personnel endpoint. This affects dashboard disaggregation by gender.

Is there a workaround?

Temporary workaround: join personnel records to Molnix/RRMS deployment/person detail externally and derive gender from:

personnel.molnix_id -> /api/api/deployments/{id} -> person.sex

However, this should be fixed in the GO sync so the gender field is populated directly in /api/v2/personnel/.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions