Skip to content

Conversation

@koct9i
Copy link
Collaborator

@koct9i koct9i commented Dec 3, 2025

  • component types and class should be valid
  • plan with class Nothing or Everything should not contain anything else

Signed-off-by: Konstantin Khlebnikov [email protected]

Copy link
Contributor

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 adds validation to the update plan configuration in Ytsaurus resources to ensure update plan consistency. The validation enforces two main rules: (1) component types specified in update plans must be valid local component types, and (2) update plans with Nothing or Everything class selectors should not contain other selectors.

Key changes:

  • Added component type validation against the LocalComponentTypes constant
  • Extended the Nothing/Everything exclusivity validation to cover both Nothing and Everything classes
  • Refactored field path construction to reduce code duplication

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

Comment on lines 584 to 586
if (hasNothing || hasEverything) && i > 0 {
allErrors = append(allErrors, field.Invalid(selectorPath, updateSelector, "Update plan with class Nothing or Everything should not contain anything more"))
}
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

The validation logic for Nothing/Everything class exclusivity is incorrect. The current condition (hasNothing || hasEverything) && i > 0 has two problems:

  1. It only triggers when processing items after the first one, so if Nothing/Everything is at index 0 followed by other items, the error is reported at the wrong location (on the second item rather than explaining that Nothing/Everything must be alone).

  2. If Nothing/Everything appears at index > 0, the error message incorrectly suggests it "should not contain anything more" when the real issue is that Nothing/Everything must be at index 0 and must be the only element.

The correct validation should check: if the current selector has Nothing or Everything class, verify that it's at index 0 AND the plan length is 1. Consider replacing with:

if updateSelector.Class == consts.ComponentClassNothing || updateSelector.Class == consts.ComponentClassEverything {
    if i != 0 || len(newYtsaurus.Spec.UpdatePlan) != 1 {
        allErrors = append(allErrors, field.Invalid(selectorPath, updateSelector, "Update plan with class Nothing or Everything must be the only element in the plan"))
    }
}

Copilot uses AI. Check for mistakes.
@koct9i koct9i force-pushed the khlebnikov/valiate-update-plan-compoennt branch 2 times, most recently from 1861b86 to a04bcaa Compare December 15, 2025 14:14
@koct9i koct9i requested a review from Copilot December 15, 2025 14:15
Copy link
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


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

@koct9i koct9i force-pushed the khlebnikov/valiate-update-plan-compoennt branch from a04bcaa to a325f56 Compare December 16, 2025 11:25
- component types and classes should be valid
- plan with class Nothing or Everything should not contain anything else

Signed-off-by: Konstantin Khlebnikov <[email protected]>
@qurname2 qurname2 force-pushed the khlebnikov/valiate-update-plan-compoennt branch from a325f56 to c147011 Compare January 6, 2026 18:48
Copy link
Collaborator

@qurname2 qurname2 left a comment

Choose a reason for hiding this comment

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

rebased from main, LGTM.

@koct9i koct9i merged commit 282ab97 into main Jan 8, 2026
9 checks passed
@koct9i koct9i deleted the khlebnikov/valiate-update-plan-compoennt branch January 8, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants