Skip to content

Fix MI::Associations::BuildResource for API Association v2.0 schema - #387

Open
Samuelfaure wants to merge 2 commits into
developfrom
fix/mi-associations-api-v2-schema
Open

Fix MI::Associations::BuildResource for API Association v2.0 schema#387
Samuelfaure wants to merge 2 commits into
developfrom
fix/mi-associations-api-v2-schema

Conversation

@Samuelfaure

Copy link
Copy Markdown
Contributor

Summary

  • The lecompteasso.associations.gouv.fr provider renamed reseaux_affiliation / composition_reseau / representants_legaux to affiliations / compositions / dirigeants (flat arrays now, instead of the old XML-emulation singular-wrapped shape). MI::Associations::BuildResource was still reading the old keys, so these three sections were silently returning empty data against live traffic.
  • PayloadParser::SINGLE_ELEMENT_COLLECTIONS now wraps the new keys the same way it already does for etablissements/agrements, so BuildResource's existing Array.wrap-based readers keep working with a minimal diff (no field-level changes needed — those were confirmed unchanged against the provider's v2.0 field reference doc and two live payloads).
  • The public v3 endpoint this powers is already deprecated: true (superseded by v4 djepva/associations), and only exposes 13 narrow fields today (none from the sections fixed here) — this closes the silent-data-loss gap without expanding scope. Remaining new v2.0 data (budgets, patrimoines, adherents_personnes_morales, etc.) is tracked separately in API-7358.

Test plan

  • bundle exec rspec spec/interactors/mi/associations/ — new fixture-backed assertions for reseaux_affiliation/composition_reseau/representants_legaux mapping, plus full existing suite green
  • bundle exec rubocop on all touched files — clean

The lecompteasso.associations.gouv.fr provider renamed reseaux_affiliation,
composition_reseau and representants_legaux to affiliations, compositions
and dirigeants respectively (flat arrays instead of the old XML-emulation
singular-wrapped shape). BuildResource was still reading the old keys, so
these three sections were silently returning empty data against live
traffic. PayloadParser's SINGLE_ELEMENT_COLLECTIONS now wraps the new keys
the same way it already does for etablissements/agrements, keeping
BuildResource's Array.wrap-based readers working with a minimal diff.

Verified field-level shapes against the provider's v2.0 field reference doc
and two live payloads (a sparse and a richly-populated real association).
Endpoint API-7358 tracks the remaining new v2.0 data (budgets, patrimoines,
adherents_personnes_morales, etc.) not yet mapped, since none of it reaches
the public serializer today.

Claude-Session: https://claude.ai/code/session_017qnKb6c2WKxbnoqpdJWUfR
@Samuelfaure
Samuelfaure requested review from Un3x and skelz0r September 3, 2026 14:34
@skelz0r

skelz0r commented Sep 3, 2026

Copy link
Copy Markdown
Member

J'hardenerai aussi la validation du schema du coup pour éviter les futures régressions. (en vrai ici faudrait même potentiellement penser à transformer toutes les payloads en json schema et monitorer si ça change dans la validation).

@skelz0r skelz0r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cf ma question.

ma remarque annexe c'est potentiellement un autre ticket.

},
"representants_legaux": [
],
"dirigeants": [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

c'est la même chose ? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bonne question, effectivement non : ce n'était pas la même chose. representants_legaux existe toujours tel quel en v2.0 (le doc a raison), les payloads que j'avais testés étaient juste des associations sans représentants légaux déclarés. dirigeants est un concept distinct, sans rapport avec ce renommage.

Corrigé dans 6772b28 : representants_legaux repasse sur sa clé d'origine, inchangée. Seuls reseaux_affiliationaffiliations et composition_reseaucompositions sont de vrais renommages, vérifiés sur plusieurs payloads réels.

…ompositions

The field reference doc's representants_legaux section is real: the top-level
key wasn't renamed in v2.0. The three sparse/empty live payloads used to spot
this were simply associations with no declared legal representatives, and
dirigeants is a separate, distinct concept (unrelated to this fix's scope).
Only reseaux_affiliation -> affiliations and composition_reseau -> compositions
were genuine renames, both independently confirmed against live payloads.

Claude-Session: https://claude.ai/code/session_017qnKb6c2WKxbnoqpdJWUfR

@skelz0r skelz0r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Je te fais confiance sur le fait que tu as vérifié que ça rendait bien sur ces 2 clés.

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