Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics not handled correctly by initMetrics.ts #1884

Closed
Innoviox opened this issue Aug 29, 2024 · 1 comment · Fixed by #2102
Closed

Metrics not handled correctly by initMetrics.ts #1884

Innoviox opened this issue Aug 29, 2024 · 1 comment · Fixed by #2102
Labels
bug Something isn't working

Comments

@Innoviox
Copy link

Version where bug was found:
dev latest (54de016)

Describe the bug
The current .env.docker.local.example has a different idea of what should be in METRICS than backend/packages/Upgrade/src/init/seed/initMetrics.ts. In the env, it is just a metrics array, but initMetrics expects an object containing a metrics and a contexts attribute. This causes MetricService.saveAllMetrics to be called with metrics=undefined, which instantly crashes the app.

To Reproduce
Install the app:

  1. git clone https://github.com/CarnegieLearningWeb/UpGrade.git
  2. cd Upgrade
  3. cd frontend && npm install
  4. cd ../backend/packages/Upgrade && npm install
  5. cd ../../../ && mv ./backend/packages/Upgrade/.env.docker.local.example ./backend/packages/Upgrade/.env.docker.local
  6. docker-compose -f singleContainerApp-docker-compose.yml up -d

Expected behavior
The backend starts up correctly.

Screenshots
image
image

Desktop (please complete the following information):

  • OS: macOS 14.1.1
  • Docker version 25.0.3, build 4debf41

Additional context
To fix this, I believe the .env.docker.local.example should have an updated METRICS that reflects its actual usage in the application. Additionally, in backend/packages/Upgrade/src/api/services/MetricService.ts, line 168, this line could be added:

private parseMetrics(metrics: Array<IGroupMetric | ISingleMetric>): IMetricUnit[] {
    // add this line since this function gets called with undefined
    if (!metrics) return [];
    // ... rest of file

to prevent issues like this from completely crashing the backend.

@Innoviox Innoviox added the bug Something isn't working label Aug 29, 2024
@RidhamShah RidhamShah self-assigned this Oct 18, 2024
@ppratikcr7 ppratikcr7 moved this to In Progress in UpGrade Project Oct 25, 2024
@ppratikcr7 ppratikcr7 self-assigned this Oct 25, 2024
@ppratikcr7
Copy link
Collaborator

@Innoviox Thanks a lot for pointing this out. We will update this and create a PR soon.

@ppratikcr7 ppratikcr7 linked a pull request Nov 11, 2024 that will close this issue
@ppratikcr7 ppratikcr7 moved this from In Progress to Code Review in UpGrade Project Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Code Review
Development

Successfully merging a pull request may close this issue.

3 participants