Fix MI::Associations::BuildResource for API Association v2.0 schema - #387
Fix MI::Associations::BuildResource for API Association v2.0 schema#387Samuelfaure wants to merge 2 commits into
Conversation
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
|
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
left a comment
There was a problem hiding this comment.
cf ma question.
ma remarque annexe c'est potentiellement un autre ticket.
| }, | ||
| "representants_legaux": [ | ||
| ], | ||
| "dirigeants": [ |
There was a problem hiding this comment.
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_affiliation → affiliations et composition_reseau → compositions 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
left a comment
There was a problem hiding this comment.
Je te fais confiance sur le fait que tu as vérifié que ça rendait bien sur ces 2 clés.
Summary
reseaux_affiliation/composition_reseau/representants_legauxtoaffiliations/compositions/dirigeants(flat arrays now, instead of the old XML-emulation singular-wrapped shape).MI::Associations::BuildResourcewas still reading the old keys, so these three sections were silently returning empty data against live traffic.PayloadParser::SINGLE_ELEMENT_COLLECTIONSnow wraps the new keys the same way it already does foretablissements/agrements, soBuildResource's existingArray.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).deprecated: true(superseded by v4djepva/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 forreseaux_affiliation/composition_reseau/representants_legauxmapping, plus full existing suite greenbundle exec rubocopon all touched files — clean