Skip to content

Conversation

@idagelic
Copy link
Member

@idagelic idagelic commented Nov 20, 2025

Update instead of save on sandbox changes

Minor refactor to use update instead of save on sandbox changes

Documentation

  • This change requires a documentation update
  • I have made corresponding changes to the documentation

Related Issue(s)

Related to updates made in #2912

@Tpuljak Tpuljak requested a review from Copilot November 20, 2025 15:27
Copy link

Copilot AI left a 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 refactors the sandbox update operations to use repository.update() instead of repository.save() for better performance and clearer intent. The changes replace entity-based save operations with direct update operations using partial objects.

Key Changes:

  • Replaced save() calls with update() across multiple sandbox modification methods
  • Introduced intermediate variables to store resolved values before assignment
  • Added conditional logic to only perform updates when necessary

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public: warmPoolSandbox.public,
labels: warmPoolSandbox.labels,
organizationId: warmPoolSandbox.organizationId,
createdAt: warmPoolSandbox.createdAt,
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The createdAt field should not be included in the update operation as it represents the original creation timestamp and should remain immutable. Including it in updates could inadvertently modify the creation time if the in-memory object has been altered.

Suggested change
createdAt: warmPoolSandbox.createdAt,

Copilot uses AI. Check for mistakes.
updateData.networkAllowList = warmPoolSandbox.networkAllowList
}

await this.sandboxRepository.update(warmPoolSandbox.id, updateData)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

After the update operation, warmPoolSandbox still contains the old data since update() doesn't refresh the entity. However, this entity is returned at line 547. Consider either refreshing the entity after update or ensuring the returned DTO accurately reflects the persisted state.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants