Skip to content

0.2-dev Fix Version Verifier #674

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

Merged
merged 2 commits into from
Mar 26, 2025
Merged

0.2-dev Fix Version Verifier #674

merged 2 commits into from
Mar 26, 2025

Conversation

mkysel
Copy link
Collaborator

@mkysel mkysel commented Mar 25, 2025

This is the fix for 0.2-dev. There will be another PR for main.

The verifier constraint on 0.2.2 was parsed as ^0.2.2 which does not allow for 0.2.0 or 0.2.1.

This now parses the constraint as ^0.2 which translates to >=0.2.0 and <0.3.0

Relates to #670. The fix to main will be closing this issue.

Summary by CodeRabbit

  • Refactor

    • Enhanced backend authentication and verification processes by integrating improved logging that offers clearer traceability for version compatibility. This streamlining of version handling helps ensure smoother and more maintainable internal synchronization.
  • Tests

    • Expanded test coverage with new scenarios that rigorously validate version compatibility across various version increments, reinforcing robust system behavior and stability.

@mkysel mkysel requested a review from a team as a code owner March 25, 2025 16:44
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request updates function signatures across authentication and server modules to include a new logger parameter of type *zap.Logger. The changes remove the previous version sanitization logic inside the claim validator and instead build the constraint directly from the server version’s major and minor numbers while logging a debug message. Additionally, test cases have been extended in claims and verifier tests to cover new version validation scenarios and logger integration in the verification process.

Changes

File(s) Change Summary
pkg/authn/claims.go, pkg/authn/verifier.go, pkg/server/server.go Updated function signatures to include a new logger parameter; removed version sanitization in NewClaimValidator and added a debug log detailing the semver constraint; modified calls so that the logger is passed through in the verification process.
pkg/authn/claims_test.go, pkg/authn/verifier_test.go Extended test cases by adding new scenarios for version validation and updated existing tests (e.g., adding testutils.NewLog(t) in verifier tests) to incorporate the logger parameter in function calls.
pkg/testutils/api/api.go Updated the call to authn.NewRegistryVerifier to include the new log parameter in the NewTestAPIServer function.

Sequence Diagram(s)

sequenceDiagram
    participant S as startAPIServer
    participant RV as NewRegistryVerifier
    participant CV as NewClaimValidator
    S->>RV: Call NewRegistryVerifier(logger, registry, myNodeID, serverVersion)
    RV->>CV: Call NewClaimValidator(logger, serverVersion)
    CV-->>RV: Return ClaimValidator
    RV-->>S: Return RegistryVerifier
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a65545f and b30f18a.

📒 Files selected for processing (1)
  • pkg/testutils/api/api.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test (Node)
🔇 Additional comments (1)
pkg/testutils/api/api.go (1)

119-124: Function signature update correctly includes logger parameter

The modification to add the log parameter to the authn.NewRegistryVerifier function call is consistent with the PR's objective to fix version verification. This change ensures the test utility properly passes the logger to the registry verifier, which will enable better debugging and tracing during the version verification process.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

macroscopeapp bot commented Mar 25, 2025

Update Version Compatibility Strategy in ClaimValidator

Modified version compatibility checking in ClaimValidator to use major and minor version components only, ignoring patch versions. Added logging capabilities to ClaimValidator and RegistryVerifier. Updated test cases to verify new version compatibility rules.

📍Where to Start

The NewClaimValidator function in claims.go which contains the core version compatibility logic changes.


Macroscope summarized b30f18a.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d81d79 and a65545f.

📒 Files selected for processing (5)
  • pkg/authn/claims.go (2 hunks)
  • pkg/authn/claims_test.go (2 hunks)
  • pkg/authn/verifier.go (2 hunks)
  • pkg/authn/verifier_test.go (1 hunks)
  • pkg/server/server.go (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
pkg/server/server.go (1)
pkg/tracing/tracing.go (1)
  • logger (27-27)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Lint-Go
🔇 Additional comments (10)
pkg/authn/verifier_test.go (1)

30-30: Properly integrated logging into the verifier creation.

The addition of the testutils.NewLog(t) parameter correctly aligns with the updated signature of NewRegistryVerifier. This change consistently propagates the logger through the authentication stack.

pkg/server/server.go (1)

274-274: Properly updated verifier instantiation with logger parameter.

The addition of the logger parameter to the NewRegistryVerifier call is correct and aligns with the updated function signature, ensuring proper logging throughout the authentication flow.

pkg/authn/claims.go (3)

7-7: Appropriate zap logger import added.

The addition of the zap logging package is necessary for the new logger parameter in NewClaimValidator.


18-18: Updated function signature to include logger parameter.

Adding the logger parameter to NewClaimValidator is consistent with the overall approach of propagating logging functionality through the authentication system.


24-28: Improved version constraint handling for compatibility.

This change correctly implements the PR objective by using a caret constraint (^major.minor) instead of the specific version constraint. The constraint now allows all versions with the same major and minor versions (including earlier patch versions), fixing the issue where versions 0.2.0 and 0.2.1 were excluded when the verifier constraint was 0.2.2.

The added log message provides valuable debug information about which constraint is being used.

pkg/authn/claims_test.go (3)

133-134: Helpful test version declarations for increased coverage.

These new version declarations provide proper setup for the additional test cases that verify the improved version constraint behavior.


161-178: Comprehensive test coverage for version compatibility rules.

The added test cases properly verify the new version constraint behavior:

  1. future-minor-rejects-us confirms that a future minor version is rejected
  2. patch-0-accepts-us verifies that the same major and minor version with a patch of 0 is accepted

These tests are crucial to validate that the fix performs as expected, allowing all patch versions within the same major and minor version.


179-184: Added test case for version 0.1.0 rejection.

This test case verifies that versions with a different minor number (in this case 0.1.0) are correctly rejected, ensuring the constraint logic works as intended.

pkg/authn/verifier.go (2)

6-6: Good addition of structured logging.

Adding zap logger integration provides better observability and structured logging capabilities, which is a best practice for Go services.


30-31: LGTM - Good dependency injection pattern.

Adding the logger as a parameter follows good dependency injection patterns instead of creating loggers internally.

@mkysel mkysel merged commit 837a398 into rel/0.2-dev Mar 26, 2025
8 checks passed
@mkysel mkysel deleted the mkysel/fix-verifier branch March 26, 2025 13:22
mkysel added a commit that referenced this pull request Mar 26, 2025
This is the fix for 0.2-dev. There will be another PR for main.

The verifier constraint on 0.2.2 was parsed as ^0.2.2 which does not
allow for 0.2.0 or 0.2.1.

This now parses the constraint as `^0.2` which translates to `>=0.2.0
and <0.3.0`

Relates to #670. The fix to main will be closing this issue.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Enhanced backend authentication and verification processes by
integrating improved logging that offers clearer traceability for
version compatibility. This streamlining of version handling helps
ensure smoother and more maintainable internal synchronization.

- **Tests**
- Expanded test coverage with new scenarios that rigorously validate
version compatibility across various version increments, reinforcing
robust system behavior and stability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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