Skip to content

fix: improve sync error messages to distinguish bad URLs from incompatible repo structures#33

Open
mohamedsedkiyouzbechi wants to merge 1 commit intomainfrom
msyo/fix/improve-sync-error-messages
Open

fix: improve sync error messages to distinguish bad URLs from incompatible repo structures#33
mohamedsedkiyouzbechi wants to merge 1 commit intomainfrom
msyo/fix/improve-sync-error-messages

Conversation

@mohamedsedkiyouzbechi
Copy link
Contributor

@mohamedsedkiyouzbechi mohamedsedkiyouzbechi commented Mar 13, 2026

  1. Problem

When repository sync fails, Promptitude shows a generic "No relevant files found" for every failure — whether the configured URL is malformed (e.g. https://github.com/org/repo/tree/main/.github) or the repository simply doesn't use a supported folder layout. Users have no way to tell what went wrong without digging into debug logs.

  1. Changes

syncManager.ts:

  • Added validateRepositoryUrl() runs before any network call and rejects GitHub URLs that contain extra path segments (like /tree/…), with a clear message explaining what format is expectedAdded validateRepositoryUrl — runs before any network call and rejects GitHub URLs that contain extra path segments (like /tree/…), with a clear message explaining what format is expected.
  • Replaced the generic "No relevant files found" error with a specific "Incompatible repository" message that lists which sync types are enabled and which branch was scanned.
  • Added a distinct message when no sync types are enabled at all.

notifications.ts

  • Updated showPartialSyncSuccess() to categorize failures in the summary toast (e.g. "Failures: 1 bad URL, 2 incompatible structure") so users can see the breakdown without clicking "Show Details."Updated showPartialSyncSuccess() to categorize failures in the summary toast (e.g. "Failures: 1 bad URL, 2 incompatible structure") so users can see the breakdown without clicking "Show Details.".

CHANGELOG.md

  • Documented the improvement under [Unreleased].
  1. Before / After
Scenario Before After
URL like .../tree/main/.github Generic "No relevant files found" Invalid URL – expected https://github.com/owner/repo but got a sub-path (…)
Repo with no supported folders Generic "No relevant files found" Incompatible repository – no .md/.txt files found under prompts/, instructions/ on branch "main"
No sync types enabled Generic "No relevant files found" No sync types enabled – enable at least one of syncChatmode, syncInstructions, or syncPrompt in settings.
Summary toast ⚠️ Partial sync completed! 0 items from 1/4 repositories. ⚠️ Partial sync: 0 items from 1/4 repos. Failures: 1 bad URL, 2 incompatible structure.
  1. Testing

Verified with npm run compile — no errors.
Tested against repos: nventive/dev-prompt-kit (passes), itschanges/awesome-chatgpt-prompts (incompatible structure), openai/openai-cookbook/tree/main/.github (bad URL), openai/openai-cookbook (incompatible structure).

Screenshot 2026-03-13 122614

Summary by CodeRabbit

  • New Features
    • Improved sync failure messages now differentiate between invalid repository URLs and incompatible repository structures.
    • Show Details view displays categorized failure counts and per-repository failure reasons.
    • Warning notifications include human-friendly failure summaries with categorized error counts.

Copilot AI review requested due to automatic review settings March 13, 2026 11:40
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Walkthrough

The changes enhance sync error handling by introducing URL validation in the sync manager and restructuring error messages to categorize failures by type (invalid URLs, incompatible structures). Notifications now display categorized failure counts with detailed per-repository reasons.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added unreleased entry documenting improved sync failure message differentiation with categorized counts and per-repo details in UI.
Sync Validation & Error Handling
src/syncManager.ts
Introduced validateRepositoryUrl() helper for URL validation; added early validation checks in sync flow; restructured "no relevant files" error handling to generate categorized error messages based on enabled sync types.
Notification Formatting
src/utils/notifications.ts
Enhanced failure notification to categorize errors by type (invalid URLs, incompatible structures, other); builds human-readable failure summary with pluralization handling.

Sequence Diagram

sequenceDiagram
    participant SyncProcess as Sync Process
    participant Manager as SyncManager
    participant Validate as validateRepositoryUrl()
    participant Results as Error Results
    participant Notifications as Notifications

    SyncProcess->>Manager: Start repository sync
    Manager->>Validate: Validate repository URL
    alt URL Valid
        Validate-->>Manager: undefined (valid)
        Manager->>Manager: Proceed with sync checks
    else URL Invalid
        Validate-->>Manager: error string
        Manager->>Results: Record URL validation error
        Manager->>Manager: Skip repository
    end
    
    Manager->>Manager: Check for relevant files
    alt No Relevant Files Found
        Manager->>Manager: Compute enabled types & structure error
        Manager->>Results: Record structure error
    end
    
    SyncProcess->>Notifications: Format failure message
    Notifications->>Results: Read categorized errors
    Notifications->>Notifications: Count invalid URLs, incompatible structures, other
    Notifications-->>SyncProcess: Return categorized failure summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main objective of the PR: improving sync error messages to distinguish between bad URLs and incompatible repository structures, which directly aligns with all the key changes across syncManager.ts, notifications.ts, and CHANGELOG.md.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch msyo/fix/improve-sync-error-messages
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can enable review details to help with troubleshooting, context usage and more.

Enable the reviews.review_details setting to include review details such as the model used, the time taken for each step and more in the review comments.

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

Improves sync error messages in the Promptitude extension to help users distinguish between malformed repository URLs and repos that lack supported folder structures.

Changes:

  • Added validateRepositoryUrl() in syncManager.ts to reject GitHub URLs with extra path segments before making network calls.
  • Replaced the generic "No relevant files found" error with context-specific messages listing enabled sync types and the scanned branch.
  • Updated showPartialSyncSuccess() in notifications.ts to categorize and summarize failures in the toast notification.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/syncManager.ts Added URL validation and improved error messages for empty sync results
src/utils/notifications.ts Categorized failure counts in partial sync toast message
CHANGELOG.md Documented the improvement under [Unreleased]

You can also share your feedback on Copilot code review. Take the survey.


const failParts: string[] = [];
if (badUrlCount > 0) { failParts.push(`${badUrlCount} bad URL${badUrlCount > 1 ? 's' : ''}`); }
if (badStructureCount > 0) { failParts.push(`${badStructureCount} incompatible structure`); }
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

🧹 Nitpick comments (1)
src/utils/notifications.ts (1)

54-61: Consider using constants for error category markers.

The string matching ('Invalid URL', 'Incompatible repository', 'No sync types enabled') creates a tight coupling between syncManager.ts and notifications.ts. If error message wording changes, categorization silently breaks.

Consider extracting shared constants or using structured error objects with an explicit category field for more robust categorization.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/notifications.ts` around lines 54 - 61, The current categorization
loop in notifications.ts relies on hard-coded substrings ('Invalid URL',
'Incompatible repository', 'No sync types enabled') which couples it to
syncManager.ts; instead define shared error category constants (e.g.,
INVALID_URL, INCOMPATIBLE_REPO, NO_SYNC_TYPES) in a common module or change
syncManager.ts to throw/return structured error objects with a category
property, then update the loop in notifications.ts to compare against those
constants or inspect err.category (refer to the errors iteration and variables
badUrlCount/badStructureCount/otherCount to locate the logic) so message wording
changes won't break categorization.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/utils/notifications.ts`:
- Around line 50-70: The pluralization for the badStructureCount category is
inconsistent: update the failParts push for badStructureCount in
src/utils/notifications.ts (the block that builds failParts using badUrlCount,
badStructureCount, otherCount) to conditionally append an "s" when
badStructureCount > 1 (e.g., use `${badStructureCount} incompatible
structure${badStructureCount > 1 ? 's' : ''}`) so it matches the pluralization
pattern used for badUrlCount and otherCount and keeps the failSummary/message
strings correct.

---

Nitpick comments:
In `@src/utils/notifications.ts`:
- Around line 54-61: The current categorization loop in notifications.ts relies
on hard-coded substrings ('Invalid URL', 'Incompatible repository', 'No sync
types enabled') which couples it to syncManager.ts; instead define shared error
category constants (e.g., INVALID_URL, INCOMPATIBLE_REPO, NO_SYNC_TYPES) in a
common module or change syncManager.ts to throw/return structured error objects
with a category property, then update the loop in notifications.ts to compare
against those constants or inspect err.category (refer to the errors iteration
and variables badUrlCount/badStructureCount/otherCount to locate the logic) so
message wording changes won't break categorization.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b08b2502-1e29-4d27-a476-d5a10504d96b

📥 Commits

Reviewing files that changed from the base of the PR and between b2f75d0 and 111ef39.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/syncManager.ts
  • src/utils/notifications.ts

Comment on lines +50 to +70
// Categorise failures so the summary toast is immediately actionable
let badUrlCount = 0;
let badStructureCount = 0;
let otherCount = 0;
for (const err of errors) {
if (err.includes('Invalid URL')) {
badUrlCount++;
} else if (err.includes('Incompatible repository') || err.includes('No sync types enabled')) {
badStructureCount++;
} else {
otherCount++;
}
}

const failParts: string[] = [];
if (badUrlCount > 0) { failParts.push(`${badUrlCount} bad URL${badUrlCount > 1 ? 's' : ''}`); }
if (badStructureCount > 0) { failParts.push(`${badStructureCount} incompatible structure`); }
if (otherCount > 0) { failParts.push(`${otherCount} other error${otherCount > 1 ? 's' : ''}`); }

const failSummary = failParts.length > 0 ? ` Failures: ${failParts.join(', ')}.` : '';
const message = `⚠️ Partial sync: ${itemsCount} items updated from ${successCount}/${totalCount} repos.${failSummary}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor pluralization inconsistency for "incompatible structure".

The pluralization for badStructureCount doesn't add an 's' when count > 1, unlike the other categories.

✏️ Proposed fix
         if (badUrlCount > 0) { failParts.push(`${badUrlCount} bad URL${badUrlCount > 1 ? 's' : ''}`); }
-        if (badStructureCount > 0) { failParts.push(`${badStructureCount} incompatible structure`); }
+        if (badStructureCount > 0) { failParts.push(`${badStructureCount} incompatible structure${badStructureCount > 1 ? 's' : ''}`); }
         if (otherCount > 0) { failParts.push(`${otherCount} other error${otherCount > 1 ? 's' : ''}`); }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/notifications.ts` around lines 50 - 70, The pluralization for the
badStructureCount category is inconsistent: update the failParts push for
badStructureCount in src/utils/notifications.ts (the block that builds failParts
using badUrlCount, badStructureCount, otherCount) to conditionally append an "s"
when badStructureCount > 1 (e.g., use `${badStructureCount} incompatible
structure${badStructureCount > 1 ? 's' : ''}`) so it matches the pluralization
pattern used for badUrlCount and otherCount and keeps the failSummary/message
strings correct.

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