fix: add runtime type guard for cpu.value in monitoring tab#4189
Merged
Siumauricio merged 1 commit intocanaryfrom Apr 9, 2026
Merged
fix: add runtime type guard for cpu.value in monitoring tab#4189Siumauricio merged 1 commit intocanaryfrom
Siumauricio merged 1 commit intocanaryfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
c.cpu.value.replace is not a functioncrash on the monitoring tab whencpu.valueis a number or null instead of a stringString()conversion with"0%"fallback, matching the defensive approach already used for memory valuesCloses #4062
Greptile Summary
This PR adds defensive runtime guards for
cpu.valuein the free container monitoring tab, wrapping it withString(value ?? "0%")to prevent crashes when the WebSocket or API response delivers a number ornullinstead of the expected string. The fix is minimal and consistent with the defensive pattern already used for memory values in the same component.Confidence Score: 5/5
Safe to merge — the crash is fixed with a targeted, consistent guard and no regressions are introduced.
The only remaining finding is a P2 type-annotation improvement that doesn't affect runtime behaviour. All P0/P1 concerns are addressed.
No files require special attention.
Comments Outside Diff (1)
apps/dokploy/components/dashboard/monitoring/free/container/show-free-container-monitoring.tsx, line 49-52 (link)The
DockerStatsinterface still declarescpu.valueasstring, but this PR exists precisely because it can arrive asnumber | nullat runtime. The?? "0%"guard is then effectively invisible to TypeScript — the compiler won't warn about future callers that use.replace()without the guard. Consider updating the type to match what the data source can actually produce:Reviews (1): Last reviewed commit: "fix: add runtime type guard for cpu.valu..." | Re-trigger Greptile