Skip to content

Conversation

@ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented Oct 24, 2025

Jira Issue: FDR-156.

Summary by CodeRabbit

  • New Features

    • Runtime configuration can now be updated at runtime with built-in validation and clearer feedback.
  • Bug Fixes / Reliability

    • Validation errors now produce consistent, user-friendly error messages and improved logging for easier troubleshooting.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

Added a private helper to centralize Zod validation error handling and a new public method updateConfig(values: AppConfig) on ConfigService that validates, applies, and resets internal state; constructor validation was refactored to use the new helper.

Changes

Cohort / File(s) Summary
ConfigService changes
packages/federation-sdk/src/services/config.service.ts
Added updateConfig(values: AppConfig) (validates with AppConfigSchema, assigns this.config, clears serverKeys, logs debug). Added private handleValidationError(err: unknown, contextMsg?: string): never to centralize ZodError formatting/logging and rethrow as unified validation error. Constructor validation now delegates to handleValidationError.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ConfigService
    participant Schema as AppConfigSchema
    participant Logger

    Client->>ConfigService: updateConfig(values)
    ConfigService->>Schema: parse/validate(values)
    alt Validation Success
        Schema-->>ConfigService: validated config
        ConfigService->>ConfigService: this.config = validated
        ConfigService->>ConfigService: this.serverKeys = {}
        ConfigService->>Logger: debug("updated serverName ...")
        ConfigService-->>Client: return / resolve
    else Zod Validation Failure
        Schema-->>ConfigService: ZodError
        ConfigService->>ConfigService: handleValidationError(err, "Configuration validation failed - check your federation settings")
        ConfigService->>Logger: error(formatted details)
        ConfigService-->>Client: throw Invalid configuration error
    else Other Exception
        Schema-->>ConfigService: exception
        ConfigService-->>Client: rethrow
    end

note over ConfigService: Constructor validation now also calls handleValidationError on ZodError
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Pay attention to the formatting and content of the unified validation error thrown by handleValidationError.
  • Verify logging context messages (constructor vs updateConfig) to ensure expected diagnostics.

Poem

🐰 A schema hop, a gentle tweak,
I validated configs this week.
Keys swept tidy, name logs bright,
No restart dance — just everything right.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Linked Issues Check ❓ Inconclusive The linked issue FDR-156 is titled "Fix restart requirements when changing settings" but no detailed requirements, acceptance criteria, or specific coding objectives are provided in the linked_issues section. Without the explicit requirements from the issue, it is impossible to verify whether the addition of the updateConfig method, the private error handling helper, and the error handling refactoring fully satisfy the objectives or if there are missing implementations needed to resolve the issue. To properly validate compliance with the linked issue, please provide the detailed requirements, acceptance criteria, and coding objectives from FDR-156. This will allow verification that all specified requirements have been implemented in the PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "chore: add updateConfig method into config service" directly and accurately describes the primary change in this pull request. It identifies both the action (adding a method) and the subject (updateConfig method in config service). The title is concise, clear, and specific enough for a teammate scanning the history to immediately understand the main addition, without unnecessary noise or vague terminology.
Out of Scope Changes Check ✅ Passed The code changes are tightly focused on the ConfigService in a single file, introducing only an updateConfig method and a supporting private error handling helper, with refactored constructor logic. The updateConfig method directly aligns with the linked issue's goal of "changing settings," and the accompanying error handling improvements serve as supporting changes. There are no unrelated modifications to other files, styling changes, documentation, or functionality outside the scope of configuration management.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch watch-settings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 52ed1db and e0b8134.

📒 Files selected for processing (1)
  • packages/federation-sdk/src/services/config.service.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/federation-sdk/src/services/config.service.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 6.89655% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.37%. Comparing base (e131461) to head (e0b8134).

Files with missing lines Patch % Lines
...ages/federation-sdk/src/services/config.service.ts 6.89% 27 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #289      +/-   ##
==========================================
- Coverage   60.49%   60.37%   -0.12%     
==========================================
  Files          67       67              
  Lines        6675     6691      +16     
==========================================
+ Hits         4038     4040       +2     
- Misses       2637     2651      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/federation-sdk/src/services/config.service.ts (1)

19-19: Critical: Type mismatch between interface and schema for signingKeyPath.

The AppConfig interface declares signingKeyPath as optional (line 19), but AppConfigSchema requires it (line 52 has no .optional()). This inconsistency will cause validation failures when signingKeyPath is undefined, breaking both the constructor and the new updateConfig method.

Apply this diff to align the schema with the interface:

-	signingKeyPath: z.string(),
+	signingKeyPath: z.string().optional(),

Also applies to: 52-52

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e131461 and 52ed1db.

📒 Files selected for processing (1)
  • packages/federation-sdk/src/services/config.service.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/federation-sdk/src/services/config.service.ts (1)
packages/federation-sdk/src/index.ts (1)
  • AppConfig (58-58)
🔇 Additional comments (3)
packages/federation-sdk/src/services/config.service.ts (3)

160-168: Verify test coverage for the new public method.

The Codecov report indicates only 4.76% patch coverage for this PR, with 20 lines missing coverage. The new updateConfig method is a public API that handles critical validation and state updates, and should have comprehensive test coverage including success cases, validation failures, and edge cases.

Please ensure tests cover:

  • Successful config updates with valid values
  • Validation failures with various invalid inputs
  • Behavior when serverKeys cache is reset
  • State consistency after failed updates

160-182: Good addition for runtime reconfiguration.

The updateConfig method provides a clean way to update configuration at runtime with proper validation and state management. The approach of resetting serverKeys after config changes ensures fresh key generation on the next access.


160-182: Concurrent access concern is theoretically valid but updateConfig is unused internally—verify external usage requirements.

updateConfig is exported publicly but has zero callers in the codebase and no test coverage. While a race condition is theoretically possible (async getSigningKey() yields control at its await, allowing updateConfig() to reset serverKeys mid-operation), this only matters if the method is actually called externally.

Verify:

  • Is updateConfig required for external SDK consumers?
  • If yes, add synchronization or atomic state updates to prevent race conditions.
  • If no, consider removing it or deferring until there's an actual use case.

@sampaiodiego
Copy link
Member

closed in favor of #292

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.

4 participants