Error when retrieving device snapshot
- Dominant language
- JavaScript
- Stars
- 400
- Forks
- 89
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 146
Description
Spotted today when a pipeline was configured with a Device Group as a target stage. All of the devices in the group were notified of a new snapshot being available when they were added to the group.
However the pipeline had not been run and there was no snapshot.
When the devices tried to get the (non-existent) snapshot, the platform returned a 500 error.
Sentry captured the underlying cause of the 500 - details below.
I haven't been able to recreate the original scenario that lead to the devices trying to retrieve a snapshot that didn't exist.
However, some validation/error handling around this scenario is needed so we don't return 500 errors.
---
Sentry Issue: [FLOWFUSE-BACKEND-2F](https://flowfuse.sentry.io/issues/4773838090/?referrer=github_integration)
```
TypeError: Cannot read properties of null (reading 'getCredentialSecret')
File "/usr/src/forge/app/node_modules/@flowfuse/flowfuse/forge/db/models/ProjectSnapshot.js", line 184, in model.getCredentialSecret
return await (await this.getProject()).getCredentialSecret()
File "node:internal/process/task_queues", line 95, in process.processTicksAndRejections
File "/usr/src/forge/app/node_modules/@flowfuse/flowfuse/forge/routes/api/deviceLive.js", line 197, in Object.
const secret = await snapshot.getCredentialSecret()
```
Contributor guide
Assessment
This issue has not been assessed yet.