-
Notifications
You must be signed in to change notification settings - Fork 115
fix(*): sentry issues that pop on container side #21786
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses Sentry issues by adding defensive null/undefined checks throughout the codebase. The changes primarily involve adding optional chaining operators to prevent runtime errors when accessing properties or methods on potentially null/undefined values.
Changes:
- Added optional chaining operators to various method calls and property accesses to prevent null/undefined errors
- Improved DOM manipulation safety by using
.remove()instead ofremoveChild()and adding parent node validation - Enhanced error handling with optional chaining on error response objects
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/manager/modules/manager-components/src/changelog-button/controller.js | Added optional chaining to chapters array reduce operation |
| packages/manager/modules/core/src/url-builder/url-builder.provider.js | Added optional chaining to Object.keys().reduce() call |
| packages/manager/core/url-builder/src/url-builder.ts | Added optional chaining to string operations and updated formatting |
| packages/manager/core/api/src/iceberg.ts | Added optional chaining to route.includes() check |
| packages/manager/apps/procedures/src/utils/iframe.ts | Enhanced iframe removal safety with parent node validation |
| packages/components/ovh-shell/src/plugin/ux/components/modal.ts | Replaced removeChild() with safer remove() method |
| packages/components/ovh-payment-method/src/ovh-payment-method.js | Added optional chaining to error response status checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| this.computedTrackingContext = this.chapters?.reduce( | ||
| (acc, value, index) => { | ||
| acc[chapterKeys[index]] = value; | ||
| return acc; | ||
| }, | ||
| {}, | ||
| ); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this.chapters is null or undefined, this.computedTrackingContext will also be undefined. This will cause an error on line 28 where it's spread into an object using the spread operator. Consider providing a fallback value such as an empty object to ensure the spread operation doesn't fail.
| this.computedTrackingContext = this.chapters?.reduce( | |
| (acc, value, index) => { | |
| acc[chapterKeys[index]] = value; | |
| return acc; | |
| }, | |
| {}, | |
| ); | |
| this.computedTrackingContext = | |
| (this.chapters?.reduce( | |
| (acc, value, index) => { | |
| acc[chapterKeys[index]] = value; | |
| return acc; | |
| }, | |
| {}, | |
| )) ?? {}; |
|
|
||
| return buildURLs( | ||
| Object.keys(routes).reduce((all, name) => { | ||
| Object.keys(routes)?.reduce((all, name) => { |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining operator is unnecessary here. Object.keys() always returns an array (possibly empty) when given an object, so it will never return null or undefined. The optional chaining suggests a misunderstanding of the API and adds unnecessary code. If routes itself could be null/undefined, the check should be on routes, not on Object.keys(routes).
| Object.keys(routes)?.reduce((all, name) => { | |
| Object.keys(routes).reduce((all, name) => { |
| let filteredParams = params; | ||
|
|
||
| if (pattern.includes(':') && params) { | ||
| if (pattern?.includes(':') && params) { |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter pattern is typed as string (non-nullable), but optional chaining is used here. This is inconsistent - either the type should allow null/undefined values (e.g., string | null | undefined), or the optional chaining should be removed. If the intention is to handle nullable values, the function signature should be updated to reflect this.
| if (pattern?.includes(':') && params) { | |
| if (pattern.includes(':') && params) { |
| if (baseURL?.includes('#') && buildedPath?.includes('#')) { | ||
| buildedPath = buildedPath.replace('#', ''); | ||
| } | ||
| if (baseURL.endsWith('/') && buildedPath.startsWith('/')) { |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent use of optional chaining on the baseURL parameter. Line 61 uses baseURL?.includes('#') with optional chaining, but line 64 uses baseURL.endsWith('/') without it. Since baseURL is typed as a non-nullable string, either both should use optional chaining (and the type should be updated), or neither should. This inconsistency suggests incomplete defensive coding.
| let queryString = queryObject ? buildQueryString(queryObject) : ''; | ||
| if (queryString) { | ||
| queryString = buildedPath.includes('?') ? `&${queryString}` : `?${queryString}`; | ||
| queryString = buildedPath?.includes('?') |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter buildedPath is derived from urlPattern.url and is guaranteed to be a string at this point. Using optional chaining here is unnecessary and suggests the code may not be handling null/undefined values correctly upstream. If buildedPath could be null/undefined, this should be addressed where it's assigned rather than using optional chaining here.
| .setIamTags( | ||
| params, | ||
| filters, | ||
| route?.includes('/iam/resource') ? 'tags' : 'iamTags', |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter route is a required string parameter in the function signature. Using optional chaining here suggests that route could be null or undefined, which contradicts the type signature. If nullable values are expected, the type should be updated to string | null | undefined. Otherwise, the optional chaining is unnecessary and masks potential bugs where null/undefined values are incorrectly passed.
| route?.includes('/iam/resource') ? 'tags' : 'iamTags', | |
| route.includes('/iam/resource') ? 'tags' : 'iamTags', |
3598fa7 to
a3bbfaf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const buildURLPattern = ( | ||
| pattern: string, | ||
| params: Record<string, ParamValueType>, | ||
| ) => { |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function signature declares pattern and params as non-nullable, but optional chaining is used on pattern at line 15. This creates a type contract inconsistency. If pattern can be null or undefined at runtime (as suggested by the defensive optional chaining), the function signature should be updated to reflect this: pattern?: string | null, params?: Record<string, ParamValueType>.
| const { params: queryObject } = urlPattern; | ||
|
|
||
| if (baseURL.includes('#') && buildedPath.includes('#')) { | ||
| if (baseURL?.includes('#') && buildedPath?.includes('#')) { |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buildURL function signature (outside the diff) declares baseURL and path as non-nullable strings, but optional chaining is used here when calling includes() on them. This creates a type contract inconsistency. If these parameters can be null or undefined at runtime (as suggested by the defensive optional chaining), the function signature should be updated to allow nullable types.
a3bbfaf to
7dc1d98
Compare
7dc1d98 to
596f0c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| this.elements.body.firstElementChild?.remove(); | ||
| this.elements.body.append(this.options.content); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chaining is applied to firstElementChild but not to this.elements.body itself. Since IModalElements defines body as optional (body?: HTMLElement), accessing this.elements.body.firstElementChild could throw an error if body is undefined. The same issue exists on line 88 with this.elements.body.append(). Both lines should use optional chaining for body as well: this.elements.body?.firstElementChild?.remove() and this.elements.body?.append(this.options.content).
ref: #MANAGER-EU-188KC Signed-off-by: Maxime Bajeux <maxime.bajeux.ext@ovhcloud.com> Co-authored-by: Dustin Kroger <dustin.kroger.ext@ovhcloud.com>
596f0c7 to
ef3c6e3
Compare
ref: #MANAGER-EU-188KC
Description
Ticket Reference: #...
Additional Information