Skip to content

Fix an exception thrown when an SSH mirror has an invalid credential type - #1336

Merged
minwoox merged 2 commits into
line:mainfrom
minwoox:fix_mirror_exception
Jul 21, 2026
Merged

Fix an exception thrown when an SSH mirror has an invalid credential type#1336
minwoox merged 2 commits into
line:mainfrom
minwoox:fix_mirror_exception

Conversation

@minwoox

@minwoox minwoox commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

…type

Motivation:
When an SSH mirror was configured with a non-SSH_KEY credential (e.g. ACCESS_TOKEN), SshGitMirror threw a MirrorException during mirror conversion. Although the exception was caught by handleAllMirrors() and the bad mirror was skipped, the mirror was invisible in the UI as a result, making it impossible to update or delete the mirror.

Modifications:

  • Move the credential type validation from SshGitMirror constructor to GitMirrorProvider.newMirror(). When the credential type is wrong, log a warning and return null instead of throwing MirrorException.

Result:

  • A mirror with an invalid credential type is loaded correctly and shown in the UI, allowing users to update or delete it.

…type

Motivation:
When an SSH mirror was configured with a non-SSH_KEY credential (e.g.
ACCESS_TOKEN), `SshGitMirror` threw a `MirrorException` during mirror
conversion. Although the exception was caught by `handleAllMirrors()` and
the bad mirror was skipped, the mirror was invisible in the UI as a result,
making it impossible to update or delete the mirror.

Modifications:

- Move the credential type validation from `SshGitMirror` constructor to
  `GitMirrorProvider.newMirror()`. When the credential type is wrong, log
  a warning and return `null` instead of throwing `MirrorException`.

Result:

- A mirror with an invalid credential type is loaded correctly and shown
  in the UI, allowing users to update or delete it.
@minwoox minwoox added this to the 0.86.0 milestone Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

SSH mirror creation now logs unexpected credential types and removes duplicate constructor validation. Mirror conversion failures in DefaultMetaRepository are promoted from DEBUG to WARN.

Changes

Mirror validation and observability

Layer / File(s) Summary
SSH credential validation
server-mirror-git/.../GitMirrorProvider.java, server-mirror-git/.../SshGitMirror.java
SSH schemes log when the credential is not an SshKeyCredential; the constructor-level type check is removed.
Mirror conversion warning logging
server/src/.../DefaultMetaRepository.java
Mirror configuration conversion failures are logged at WARN level with the project, configuration, and exception.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • line/centraldogma#1316: Updates handling and logging of mirror conversion failures in DefaultMetaRepository.handleAllMirrors.

Suggested reviewers: ikhoon, trustin

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change: handling invalid SSH mirror credentials and the resulting exception.
Description check ✅ Passed The description matches the PR's behavior change and UI motivation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/GitMirrorProvider.java`:
- Around line 53-57: Update GitMirrorProvider.newMirror() so an SSH mirror with
a missing credential, represented by Credential.NONE, remains loadable instead
of being rejected and dropped by handleAllMirrors(). Preserve the existing
validation for non-SSH credential types, or alternatively enforce rejection when
the mirror is written through the relevant write path rather than during
loading.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53bc289c-1703-47f9-a287-072c7c0db335

📥 Commits

Reviewing files that changed from the base of the PR and between 5bc736b and c125124.

📒 Files selected for processing (3)
  • server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/GitMirrorProvider.java
  • server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/SshGitMirror.java
  • server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/DefaultMetaRepository.java
💤 Files with no reviewable changes (1)
  • server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/SshGitMirror.java

@minwoox
minwoox marked this pull request as ready for review July 16, 2026 04:43
@minwoox
minwoox requested review from ikhoon and jrhee17 as code owners July 16, 2026 04:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/GitMirrorProvider.java (1)

53-56: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Return null and log at WARN for invalid SSH credentials.

This branch currently logs at DEBUG and continues creating SshGitMirror. Since constructor validation was removed, credentials such as ACCESS_TOKEN are now accepted instead of being rejected as required by this PR.

🐛 Proposed fix
                 if (!(context.credential() instanceof SshKeyCredential)) {
-                    logger.debug("'{}': SSH mirror requires an SSH_KEY credential, " +
-                                "but got: {}", context.id(), context.credential().type());
+                    logger.warn("'{}': SSH mirror requires an SSH_KEY credential, " +
+                                "but got: {}", context.id(), context.credential().type());
+                    return null;
                 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/GitMirrorProvider.java`
around lines 53 - 56, Update the invalid-credential branch in the mirror
creation flow to log the SSH credential mismatch at WARN level and return null
immediately, preventing SshGitMirror creation when context.credential() is not
an SshKeyCredential.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In
`@server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/GitMirrorProvider.java`:
- Around line 53-56: Update the invalid-credential branch in the mirror creation
flow to log the SSH credential mismatch at WARN level and return null
immediately, preventing SshGitMirror creation when context.credential() is not
an SshKeyCredential.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4cbca470-b269-45f0-ae56-cf91b856778c

📥 Commits

Reviewing files that changed from the base of the PR and between c125124 and e8a3f18.

📒 Files selected for processing (1)
  • server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/GitMirrorProvider.java

@jrhee17 jrhee17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 👍


switch (scheme) {
case SCHEME_GIT_SSH: {
if (!(context.credential() instanceof SshKeyCredential)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question) Could we validate the configuration correctness also when a mirror is created.?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ikhoon ikhoon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 👍

@minwoox minwoox changed the title Fix an exception thrown when an SSH mirror has an invalid credential … Fix an exception thrown when an SSH mirror has an invalid credential type Jul 21, 2026
@minwoox
minwoox merged commit 31898f0 into line:main Jul 21, 2026
14 checks passed
@minwoox
minwoox deleted the fix_mirror_exception branch July 21, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants