Skip to content

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Dec 11, 2025

The error was caused by Obsidian internally normalize the folder path when we call vault.createFolder(). eg: if we have Discourse Canvas/ saved, then when normalized we have Discourse Canvas, which already exists. I made sure to normalize the name in both Saving and Creating step -> remove the error.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved folder path handling in General Settings to automatically trim whitespace and normalize path formatting for configuration folders, ensuring cleaner and more reliable settings storage.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link

linear bot commented Dec 11, 2025

@supabase
Copy link

supabase bot commented Dec 11, 2025

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@trangdoan982 trangdoan982 force-pushed the eng-1072-error-when-setting-canvas-folder-path-to-root branch from 22df988 to 543550e Compare December 11, 2025 01:28
@trangdoan982
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

📝 Walkthrough

Walkthrough

The changes enhance path handling consistency by introducing whitespace trimming in the GeneralSettings save operation for folder paths and implementing path normalization in the file utilities module before operations are performed.

Changes

Cohort / File(s) Summary
Folder path trimming on save
apps/obsidian/src/components/GeneralSettings.tsx
Save operation now trims whitespace from nodesFolderPath, canvasFolderPath, and canvasAttachmentsFolderPath before persisting to settings.
Path normalization in file operations
apps/obsidian/src/utils/file.ts
Introduced normalizedPath variable; folder path is normalized before retrieval, error messaging, and folder creation operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Both changes follow consistent patterns: trim/normalize at entry point and use normalized value throughout
  • Limited scope with only 2 files affected
  • Simple string operations with no complex control flow changes

Possibly related PRs

Pre-merge checks

✅ 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 directly references the main issue being fixed: the error when creating a new canvas, which aligns with the changes made to trim folder paths and normalize them to prevent folder-already-exists errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

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)
apps/obsidian/src/utils/file.ts (1)

3-12: Good call normalizing paths before vault operations; consider trimming defensively

Using normalizePath once and reusing normalizedPath for both getAbstractFileByPath and createFolder is a solid improvement and should prevent “folder already exists” errors when users enter equivalent-but-different paths (e.g. extra slashes).

You could additionally guard against future callers passing whitespace-only values by trimming first, e.g.:

const trimmed = folderpath.trim();
if (!trimmed) return;
const normalizedPath = normalizePath(trimmed);

so these are treated like “no folder” rather than trying to create a folder named with stray spaces.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fbe00d and 543550e.

📒 Files selected for processing (2)
  • apps/obsidian/src/components/GeneralSettings.tsx (1 hunks)
  • apps/obsidian/src/utils/file.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/main.mdc)

**/*.{ts,tsx}: Use Tailwind CSS for styling where possible
When refactoring inline styles, use tailwind classes
Prefer type over interface in TypeScript
Use explicit return types for functions
Avoid any types when possible
Prefer arrow functions over regular function declarations
Use named parameters (object destructuring) when a function has more than 2 parameters
Use PascalCase for components and types
Use camelCase for variables and functions
Use UPPERCASE for constants
Function names should describe their purpose clearly
Prefer early returns over nested conditionals for better readability

Files:

  • apps/obsidian/src/utils/file.ts
  • apps/obsidian/src/components/GeneralSettings.tsx
apps/obsidian/**

📄 CodeRabbit inference engine (.cursor/rules/obsidian.mdc)

apps/obsidian/**: Prefer existing dependencies from apps/obsidian/package.json when adding dependencies to the Obsidian plugin
Follow the Obsidian style guide from help.obsidian.md/style-guide and docs.obsidian.md/Developer+policies for UI and code styling
Use Lucide and custom Obsidian icons alongside detailed elements to provide visual representation of features in platform-native UI

Files:

  • apps/obsidian/src/utils/file.ts
  • apps/obsidian/src/components/GeneralSettings.tsx

@trangdoan982 trangdoan982 merged commit ab7d3cd into main Dec 15, 2025
4 checks passed
@trangdoan982 trangdoan982 deleted the eng-1072-error-when-setting-canvas-folder-path-to-root branch December 15, 2025 15:24
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.

3 participants