OpenFn / grassroot-soccer

Grassroot Soccer CommCare-Salesforce integrations
https://openfn.github.io/grassroot-soccer/
0 stars 0 forks source link

GRS Motech CommCare submission error #12

Closed sentry-io[bot] closed 2 years ago

sentry-io[bot] commented 3 years ago

Something is off with the form submission that's making the XML parser blow up. See email "MOTECH Error" for more details.

Sentry Issue: PLATFORM-1DK

ArgumentError: argument error
  File "lib/funky_xml.ex", line 80, in FunkyXML.Plug.decode/1
    e -> reraise Plug.Parsers.ParseError, exception: e
  File "lib/plug/parsers.ex", line 339, in Plug.Parsers.reduce/8
  File "lib/open_fn_web/controllers/inbox_controller.ex", line 1, in OpenFnWeb.InboxController.phoenix_controller_pipeline/2
    defmodule OpenFnWeb.InboxController do
  File "lib/phoenix/router.ex", line 352, in Phoenix.Router.__call__/2
  File "lib/open_fn_web/endpoint.ex", line 1, in OpenFnWeb.Endpoint.plug_builder_call/2
    defmodule OpenFnWeb.Endpoint do
...
(3 additional frame(s) were not displayed)

(ArgumentError argument error)
taylordowns2000 commented 3 years ago

Update: the client doesn't actually want to send XML to OpenFn. We're updating this to throw a more useful 422 when XML that we can't parse arrives.

taylordowns2000 commented 3 years ago

@stuartc , i'm happy with the current 400 from PlugParser, but these are payloads that could help us figure out why it's unable to parse. the first 2 work and the 3rd fails. All data is fake so this can be used for testing if necessary:

handled by funkyXML properly:

<?xml version="1.0" ?>
<case case_id="63e0d40e-57d5-446b-83d6-e90ca12ac550" date_modified="2021-05-17T10:08:12.583000Z" user_id="ca24020f51944772b6ee3a9fe5997d3b" xmlns="http://commcarehq.org/case/transaction/v2">
    <create>
        <case_type>other_events</case_type>
        <case_name>XXXXXXXXXX Border Community Health Event 2021-05-11</case_name>
        <owner_id>ca24020f51944772b6ee3a9fe5997d3b</owner_id>
    </create>
    <update>
        <date_opened>2021-05-11</date_opened>
        <Event_Name>XXXXXXXXXX Border Community Health Event 2021-05-11</Event_Name>
        <business_unit_event>65680f0c4c144b03ad0f86bdc46c1ebc</business_unit_event>
        <country_custom_code>ZM</country_custom_code>
        <does_country_have_mental_health_assessments>Yes</does_country_have_mental_health_assessments>
        <does_country_have_skillz_plus_club>Yes</does_country_have_skillz_plus_club>
        <does_venue_do_malaria_testing>No</does_venue_do_malaria_testing>
        <event_date>2021-05-11</event_date>
        <event_type>community_health_event</event_type>
        <site_code_event>0d653cfe9b3b48878e25fed7707d18e8</site_code_event>
        <site_country>7cd352d69f07457790281a5b48df983d</site_country>
        <site_event>0d653cfe9b3b48878e25fed7707d18e8</site_event>
        <test_real>FAKE</test_real>
        <tested_for_hiv>1</tested_for_hiv>
        <venue_code_event>6c5bca68378945e5bfe8aa34d6cfb095</venue_code_event>
        <venue_custom_code>1</venue_custom_code>
        <venue_event>6c5bca68378945e5bfe8aa34d6cfb095</venue_event>
    </update>
</case>
<?xml version="1.0" ?>
<case case_id="21b819cf-00c8-4a99-a100-0fa52ed6563b" date_modified="2021-05-17T10:08:12.583000Z" user_id="ca24020f51944772b6ee3a9fe5997d3b" xmlns="http://commcarehq.org/case/transaction/v2">
    <create>
        <case_type>skillz_plus_club_participant</case_type>
        <case_name>aicha fake test diallo</case_name>
        <owner_id>ca24020f51944772b6ee3a9fe5997d3b</owner_id>
    </create>
    <update>
        <date_opened>2021-05-17</date_opened>
        <age_in_years>8</age_in_years>
        <class>testt</class>
        <date_of_birth>2013-05-17</date_of_birth>
        <gender>female</gender>
        <grade>tet</grade>
        <mobile_number>0260889658589</mobile_number>
        <participant_first_name>aicha fake</participant_first_name>
        <participant_full_name>fake diallo</participant_full_name>
        <participant_surname>diallo</participant_surname>
        <school_name>test</school_name>
        <skillz_plus_number>ZM-1007</skillz_plus_number>
    </update>
</case>

and this blows up

<?xml version="1.0" ?>
<case case_id="1c29db00-b434-4b0f-bd87-57a0fbed4f44" date_modified="2021-05-17T10:08:12.583000Z" user_id="ca24020f51944772b6ee3a9fe5997d3b" xmlns="http://commcarehq.org/case/transaction/v2">
    <create>
        <case_type>other_event_referral</case_type>
        <case_name>fake test</case_name>
        <owner_id>ca24020f51944772b6ee3a9fe5997d3b</owner_id>
    </create>
    <update>
        <date_opened>2021-05-17</date_opened>
        <age_group>0 - 9</age_group>
        <age_in_years>8</age_in_years>
        <art_support>art_initiationenrollment clinic-based_support_group pmtct</art_support>
        <child_protection>suspected_abuse_reported_police_court_other_authority post_violence_care_medical_legal_counseling child_support_grant_social_foster_general_support other</child_protection>
        <child_protection_abuse_reported_to>court</child_protection_abuse_reported_to>
        <child_protection_child_support_grant_for>social</child_protection_child_support_grant_for>
        <child_protection_type_of_post_violence_care>medical</child_protection_type_of_post_violence_care>
        <count_child_protection_support_services>4</count_child_protection_support_services>
        <count_legal_services>2</count_legal_services>
        <count_mental_health_services>3</count_mental_health_services>
        <count_of_art_support_services>3</count_of_art_support_services>
        <count_of_hiv_support_care>6</count_of_hiv_support_care>
        <count_other_srhr_services>9</count_other_srhr_services>
        <event_type>Community Health Event</event_type>
        <gender>female</gender>
        <hiv_support_care>hiv_testing_services tb_screening_treatment_adherence vmmc post_exposure_prophylaxis prep other</hiv_support_care>
        <legal_services>birth_certificate id</legal_services>
        <mental_health_services>iptg_to_health_facility iptg_specialised_to_smz iptg_specialised_outside_smz</mental_health_services>
        <other_child_protection>test</other_child_protection>
        <other_hiv_support_care/>
        <srhr_services>sti_screening_diagnosis_treatment contraceptivesfamily_planning cervical_cancer_screening hpv antenatal_care_anc sexual__gender-based_violenceabus drug_or_alcohol_abuse psychiatric_careintensive_counseling psychosocial_support</srhr_services>
        <test_real>Real</test_real>
    </update>
    <index>
        <parent case_type="other_events">63e0d40e-57d5-446b-83d6-e90ca12ac550</parent>
    </index>
</case>