pnp / copilot-pro-dev-samples

Community contributed samples for the Microsoft 365 Copilot. Contributions welcome.
MIT License
19 stars 11 forks source link

Error in SnowWizard while running GET /api/incidents: TypeError: Cannot read properties of undefined (reading 'length') #15

Open acamina opened 1 week ago

acamina commented 1 week ago

get this errors while running the example :

[2024-11-02T17:10:08.915Z] Executing 'Functions.incidents' (Reason='This function was programmatically called via the host APIs.', Id=7e0fa89a-ed9f-47ee-b747-56b6a8f839d5) [2024-11-02T17:10:09.093Z] Ô×í´©Å POST /api/incidents: [2024-11-02T17:10:09.961Z] User fetched successfully from ServiceNow: undefined [2024-11-02T17:10:09.969Z] Error creating incident: TypeError: Cannot read properties of undefined (reading '0') [2024-11-02T17:10:09.977Z] at IncidentsApiService. (C:\Temp-open\da-SnowWizard\SnowWizard\dist\src\services\snow_incidents.js:184:40) [2024-11-02T17:10:09.982Z] at Generator.next () [2024-11-02T17:10:09.988Z] at fulfilled (C:\Temp-open\da-SnowWizard\SnowWizard\dist\src\services\snow_incidents.js:30:58) [2024-11-02T17:10:09.992Z] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) [2024-11-02T17:10:09.999Z] ÔØî GET /api/incidents: TypeError: Cannot read properties of undefined (reading '0') [2024-11-02T17:10:10.122Z] Executed 'Functions.incidents' (Succeeded, Id=7e0fa89a-ed9f-47ee-b747-56b6a8f839d5, Duration=1285ms) [2024-11-02T17:10:34.625Z] Executing 'Functions.incidents' (Reason='This function was programmatically called via the host APIs.', Id=c7bceda8-ce12-4a82-bb2a-3eb39d0f8772)

cristianoag commented 6 days ago

Since authentication was not implemented yet, the application uses a specific user account to create incidents. You can modify this user’s email in the incidents.ts file. However, the recommended approach is to authenticate the user on the Copilot side, utilizing the current user's credentials to create incidents. This example is for demonstration purposes only.

In the log file you provided (see below), the user fred.luddy@example.com—which is valid in the sample ServiceNow tenant available through the development program—is showing as undefined in your environment.

[2024-11-02T17:10:09.961Z] User fetched successfully from ServiceNow: undefined