AmericaSCORESBayArea / AmericaScores-CoachApp

React native based mobile app for Americas scores attendance management
5 stars 2 forks source link

(Bug) Session Create Fails for Bridges Academy Teams #487

Open CritiqalPete opened 6 months ago

CritiqalPete commented 6 months ago

See below for callstack for Coach App.

mysteriously, this issue appears isolated to two team seasons: a0qUQ000001q9ufYAA (Bridges Girls 2023-2024) a0qUQ000001qI3VYAU (Bridges Boys 2023-2024)

To observe:

  1. login with a credential assigned to one of the above team seasons
  2. navigate to the team > Sessions
  3. +Add Session and select a reasonable date and Submit Result: Generic Error Message

No session is created in the DB. Response suggests an incomplete request is being sent but this appears isolated to these team seasons only

May need parallel investigation on Salesforce DB.

Error (from Salesforce)

"message": "Required fields are missing: [Team_Season__c]

API LOGS

10:48:31.422     05/02/2024     Worker-0     [MuleRuntime].uber.1008: [salesforce-data-api-prod].post:\sessions:application\json:salesforce-data-api-config.BLOCKING @280e2775     DEBUG
event:30867510-08ac-11ef-a71e-02bf0f2bd7d7 Sending request to Salesforce. Arguments: {request=<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header><SessionHeader xmlns="urn:partner.soap.sforce.com"><sessionId>00D50000000NVw6!AQEAQNmMdlhO95B_o4qetqn2kUO0Ke3.I5tWSgPmsf.FU4KZr6KeyQ6QxdHCNNOUTeF7PvBb1T50jj.Kt3.KsU1jAp.H_crM</sessionId></SessionHeader></env:Header><env:Body><m:create xmlns:m="urn:partner.soap.sforce.com" xmlns:sobj="urn:sobject.partner.soap.sforce.com"><m:sObjects><sobj:type xsi:type="xsd:string">Session__c</sobj:type><sobj:Session_Date__c xsi:type="xsd:date">2024-04-22T00:00:00.000Z</sobj:Session_Date__c><sobj:Session_Topic__c xsi:type="xsd:string">Soccer</sobj:Session_Topic__c><sobj:Team_Season__c xsi:type="xsd:string"></sobj:Team_Season__c></m:sObjects></m:create></env:Body></env:Envelope>, endpoint=https://americascoresbayarea.my.salesforce.com/services/Soap/u/48.0/00D50000000NVw6}.
10:48:31.755     05/02/2024     Worker-0     [MuleRuntime].uber.1008: [salesforce-data-api-prod].post:\sessions:application\json:salesforce-data-api-config.BLOCKING @280e2775     DEBUG
event:30867510-08ac-11ef-a71e-02bf0f2bd7d7 Receiving response from Salesforce. Arguments: {endpoint=https://americascoresbayarea.my.salesforce.com/services/Soap/u/48.0/00D50000000NVw6, response=<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><LimitInfoHeader><limitInfo><current>1344</current><limit>120000</limit><type>API REQUESTS</type></limitInfo></LimitInfoHeader></soapenv:Header><soapenv:Body><createResponse><result><errors><fields>Team_Season__c</fields><message>Required fields are missing: [Team_Season__c]</message><statusCode>REQUIRED_FIELD_MISSING</statusCode></errors><id xsi:nil="true"/><success>false</success></result></createResponse></soapenv:Body></soapenv:Envelope>}.

Coach App runtime shows:

TypeError: Cannot read properties of null (reading 'toString')
    at ActivitiesScreen.<anonymous> (Activities.Screen.js:480:48)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (asyncToGenerator.js:3:24)
    at _next (asyncToGenerator.js:22:9)
    at tryCallOne (core.js:37:12)
    at core.js:123:15
    at JSTimers.js:247:18
    at _callTimer (JSTimers.js:111:7)
    at _callReactNativeMicrotasksPass (JSTimers.js:161:5)
    at MessageQueue.callReactNativeMicrotasks [as _reactNativeMicrotasksCallback] (JSTimers.js:415:12)

Activities.Screen.js:166-199

async _syncActivities() {
    const { route } = this.props;
    //Syncs activities from endpoint
    await this.fetchActivities()
      .then((activitiesList) => this._syncReduxActivities(activitiesList))
      .then(async () => {
        //Check if we are in the team activities name
        this.setState({ offset: this.state.offset + 15 });
        if (
          route.name === "Team Sessions" &&
          route.params &&
          route.params.teamSeasonId &&
          route.params.region &&
          route.params.teamName
        ) {
          if (this.state.offset === 15) {
            await this.fetchStudents();
          }
          await this.filterActivitiesByTeamSeasonId(
            //route.params.teamSeasonId,
            route.params.region,
            route.params.teamName
          ); // filter the activities for a specific team
          this.setState({
            isUpdated: true,
            teamSeasonId: route.params.teamSeasonId,
            region: route.params.region,
            teamName: route.params.teamName,
            isTeamSessions: true,
            programType: route.params.ProgramType,
          });
        }
      })
      .catch((error) => console.log(error));

Presumably the implementation here has undergone some changes for certain conditions and is likely due maintenance, but the NULL condition seems prior to the function failing.

CritiqalPete commented 6 months ago

I tried assigning one of these team seasons' writing coach roles to Yuri Morales and it's not showing up in his view. Beginning to suspect a record malform.

@lautirozen FYI

CritiqalPete commented 6 months ago

The issue starts earlier in the flow. Simply choosing one of the teams from the Teams list which opens the Activities view, reports and error. TypeError: Cannot read properties of null (reading 'toString') adding to bug detail.

CritiqalPete commented 6 months ago

we need to determine if the TeamSeasonID is being lost by the app (it's already received the ID in order to display the list of Teams) LIKELY CULPRIT or if the API is sending the ID a second time as a NULL and that is displacing the correct value CHECK API LOGS

CritiqalPete commented 6 months ago

seeing this when I drill down from the Teams list on Bridges Boys to view the list of Sessions. Two should appear but the view remains empty. This is in the debugger: [TypeError: Cannot read property 'toString' of null]

CritiqalPete commented 6 months ago

This happens again when I start the Create Session flow. [TypeError: Cannot read property 'match' of null]

CritiqalPete commented 6 months ago

This is what is logged when I pick a date and submit:

{"SessionDate": "2024-04-23", "SessionTopic": "Soccer", "TeamSeasonId": "", "sessionEnd": "14:00", "sessionStart": "13:00"}

 LOG  changes {"SessionDate": "2024-04-23", "SessionTopic": "Soccer", "TeamSeasonId": "", "sessionEnd": "14:00", "sessionStart": "13:00"}

Why is TeamSeasonID blank???

CritiqalPete commented 6 months ago

This seems like an error in the Calendar component or date parsing. I eventually get the app to hang when I select a date range.

Image

CritiqalPete commented 6 months ago

Cause identified and (temporarily) fixed: The Account Record was missing a value for "Regionc" (Team_Seasonr.Teamr.School_Siter.Region__c references an AccountID)

When I assigned this Account to 'Oakland' the bug went away

Need to think about protections on the Salesforce side as well as any App that uses strategies like this for filtering/ordering.

Leaving Aptos Account unchanged so we can test further.