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

fix(server): fix instance task error #988

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/src/instance/instance-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class InstanceTaskService {
const instance = await this.instanceService.get(app)
const available = isConditionTrue(
'Available',
instance.deployment.status?.conditions,
instance.deployment?.status?.conditions || [],
)
if (!available) {
await this.relock(appid, waitingTime)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:

The code patch looks good, and it appears the intent is to check if the deployment status condition is true. It looks like the code is trying to access the instance object and check the deployment status condition.

However, there is a bug risk because the instance object might be null. To prevent this, the code should add a check for null before attempting to access the instance object. Additionally, the code should check if the instance.deployment object is also not null before accessing the status conditions.

The code patch can be improved by adding more defensive programming. For example, the code can check for any edge cases that could lead to an error and handle those cases gracefully. The code should also include more comments to explain what it is doing and why.

Expand Down