fix: resolve TypeError in api - #3145
Open
oneuptime-test[bot] wants to merge 1 commit into
Open
Conversation
This commit fixes an exception detected by OneUptime. Exception Type: TypeError Exception ID: fda507de-a244-4038-9a65-d902b4d6fa20 Automatically generated by OneUptime AI Agent.
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Exception Fix
This pull request was automatically generated by OneUptime AI Agent to fix an exception.
Exception Details
Service: api
Type: TypeError
Message (dynamic values and secrets redacted): Cannot read properties of undefined (reading 'getModel')
Stack Trace
Summary of Changes
The fix is complete. Let me provide a summary of what changed and why.
Summary
Root Cause: In
MonitorStepsProjectValidator.ts, theSERVICE_BY_MODEL[reference.model]lookup could returnundefinedif a reference model didn't have a corresponding service mapping. Thisundefinedvalue was passed as theserviceproperty toProjectScopedReferenceValidator.validateReferencesBelongToProject(), which then attempted to callservice.getModel()onundefined, causing theTypeError: Cannot read properties of undefined (reading 'getModel').Fix: Modified
Common/Server/Utils/Monitor/MonitorStepsProjectValidator.tsto:projectScopedReferencesarray explicitly in a loop instead of using.map()inlineundefinedand skip those references withcontinueThis is a targeted fix at the call site (per the hard rules: "NEVER change shared utilities or cross-cutting contracts to suppress a single call site's error; fix the call site"). The fix:
This PR was automatically generated by OneUptime AI Agent
ℹ️ Verification
Not verified — the repository has no setup/build/test commands configured. Configure them on the code repository to have fixes verified before the pull request opens.