Skip to content

fix: consolidate marker parsing + canonicalize mount paths#2

Open
Dhravya wants to merge 6 commits intofeat/import-existing-on-mountfrom
fix/marker-consolidation
Open

fix: consolidate marker parsing + canonicalize mount paths#2
Dhravya wants to merge 6 commits intofeat/import-existing-on-mountfrom
fix/marker-consolidation

Conversation

@Dhravya
Copy link
Copy Markdown
Member

@Dhravya Dhravya commented Apr 25, 2026

Summary

  • Deduplicate .smfs marker parsing — was copy-pasted in marker.rs, unmount.rs, and inline in grep.rs. Now there's one parse_marker() and find_marker_from() in marker.rs.
  • Reject empty container_tag values in marker files (previously container_tag=\n would silently produce an empty tag).
  • Canonicalize mount_path before writing to the .smfs marker so downstream readers always get absolute paths regardless of how the mount was invoked.

Test plan

  • Mount with relative path, verify .smfs marker contains absolute mount_path
  • smfs unmount . still works (uses shared find_marker_from)
  • smfs grep from outside mount dir still resolves marker correctly
  • Corrupt .smfs with container_tag= (empty value) — should fail gracefully

🤖 Generated with Claude Code

Dhravya and others added 6 commits April 24, 2026 22:14
When mounting to a non-empty directory, detect existing files and
prompt the user to import them into the container. Also fixes
`smfs mount .` and `smfs unmount .` which previously failed because
`.` was used as a literal container tag / couldn't walk up to find
the .smfs marker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…unt paths

- Deduplicate .smfs marker parsing (was copy-pasted in marker.rs,
  unmount.rs, and grep.rs) into shared parse_marker/find_marker_from
- Reject empty container_tag values in marker files
- Canonicalize mount_path before writing to .smfs marker so
  downstream readers always get absolute paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@vorflux vorflux Bot left a comment

Choose a reason for hiding this comment

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

Reviewed — found 1 issue.


Review with Vorflux

Comment on lines +68 to +78
let canonical_mount = cfg
.mount_path
.canonicalize()
.unwrap_or_else(|_| cfg.mount_path.clone());
std::fs::write(
&marker_path,
format!(
"container_tag={}\napi_url={}\nmount_path={}\n",
cfg.container_tag,
cfg.api_url,
cfg.mount_path.display(),
canonical_mount.display(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium: canonicalizing the mount path in the marker breaks project-scoped credential lookups for non-canonical mounts.

The marker now stores mount_path as the canonicalized path, but the credential system (save_project, load_project, remove_project in smfs-core/src/config/credentials.rs) keys project credentials by whatever raw path string was passed at smfs mount time — it calls project_path(mount_path) which just encodes the path as-is without canonicalizing.

This means:

  • A mount created with --path ./mnt, --path ../mnt, or a symlinked path saves credentials under the original path key.
  • Later, smfs grep reads the marker and gets back the canonicalized path, then calls load_project with that canonical path — a different key — so it misses the project credential and falls back to global creds or fails with "API key required".
  • smfs logout --project will call remove_project with the canonical path, report success (because NotFound is treated as success), but leave the original project credential file on disk.

Suggested fix: Apply the same normalization strategy everywhere. The simplest approach is to canonicalize in project_path() (or in a shared helper called by all of save_project/load_project/remove_project), so the credential key is always canonical regardless of how the path was originally passed. Alternatively, keep the raw path in the marker and remove the canonicalization added here.

@Prasanna721 Prasanna721 force-pushed the feat/import-existing-on-mount branch from 26c9d85 to ba83d50 Compare April 29, 2026 19:03
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.

1 participant