Skip to content

fix(project): keep a copy of an unreadable project config before defaults replace it - #4420

Draft
richiemcilroy wants to merge 2 commits into
mainfrom
fix/project-config-keep-unreadable
Draft

richiemcilroy wants to merge 2 commits into
mainfrom
fix/project-config-keep-unreadable

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

When project-config.json exists but can't be read, every caller falls back to a default configuration, and the next save writes that default over the file. All zooms, captions, text, clips and cuts in it are gone, with no warning.

flowchart LR
    A[project-config.json<br/>written by a newer Cap,<br/>or edited by hand] -->|serde / validate error| B[ProjectConfiguration::load<br/>InvalidData]
    B --> C[RecordingMeta::project_config<br/>returns default]
    B --> D[load#40;#41;.unwrap_or_default#40;#41;<br/>clips, screenshot editor, overlay]
    C --> E[editor builds a timeline<br/>project.write]
    D --> F[next edit<br/>project.write]
    E --> G[original edits lost]
    F --> G
Loading
  • RecordingMeta::project_config (crates/project/src/meta.rs:303) maps every non-NotFound error to ProjectConfiguration::default(). The editor then sees no timeline and saves one (crates/editor/src/editor_instance.rs).
  • The GPUI app has the same load().unwrap_or_default() then write pattern in editor_clips.rs (append clip), screenshot_editor.rs and recordings_overlay.rs.
  • load fails on any enum value this build doesn't know. None of the configuration enums has a fallback variant. It also fails when validate() rejects an annotation. A project opened in an older build after a newer one saved it is enough.

Fix

ProjectConfiguration::load keeps a copy of the file before returning the parse or validation error:

let mut config: Self = serde_json::from_str(&config_str).map_err(|error| {
    keep_unreadable_config(&config_path, &config_str);
    std::io::Error::new(std::io::ErrorKind::InvalidData, error)
})?;
  • The copy sits next to the file as project-config.json.unreadable-<hash of contents>, written to a temp file and renamed into place. Loading the same unreadable file again doesn't add copies. A different unreadable version gets its own.
  • Everything else is unchanged: the same error, the same fallbacks in the callers, and nothing extra on the normal path.
Unreadable project-config.json, then a default is saved Before After
Original contents overwritten kept in project-config.json.unreadable-<hash>
Loading the same file again n/a no extra copy
Readable config no extra files no extra files

RetriggerView in GreptileConfidence Score: 4/5

Add a safe fallback for exFAT backup writes before merging.

Findings

  1. P1 Backups fail on exFAT ▶
Fix with agent prompt
### Issue 1
crates/project/src/configuration.rs:3896-3898
**Backups fail on exFAT.** On macOS exFAT drives and some network volumes, `persist_noclobber` fails with `ENOTSUP`. The export code already handles this case in `persist_without_replacing`. Here, the error only produces a log warning and the temporary copy is dropped. Callers still use defaults and save over the original, leaving no recovery copy. The previous plain rename worked on these drives.

Add a safe fallback for filesystems that cannot support `persist_noclobber`, while keeping the protection against existing files and symlinks.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR keeps recovery copies of unreadable project settings before callers replace them with defaults.

  • Unreadable project configs get a recoverable copy before loading fails.

Reviews (2) · Last reviewed commit: "fix(project): keep non-UTF-8 configs and..." · Reviewed by Greptile

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Ignored Ignored Preview Nov 20, 2026 12:54am UTC

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

Comment thread crates/project/src/configuration.rs Resolved
Comment thread crates/project/src/configuration.rs Resolved
@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

Comment on lines +3896 to +3898
staged
.persist_noclobber(&backup)
.map_err(|error| error.error)?;

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.

P1 Backups fail on exFAT. On macOS exFAT drives and some network volumes, persist_noclobber fails with ENOTSUP. The export code already handles this case in persist_without_replacing. Here, the error only produces a log warning and the temporary copy is dropped. Callers still use defaults and save over the original, leaving no recovery copy. The previous plain rename worked on these drives.

Add a safe fallback for filesystems that cannot support persist_noclobber, while keeping the protection against existing files and symlinks.

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/project/src/configuration.rs
Line: 3896-3898

Comment:
**Backups fail on exFAT.** On macOS exFAT drives and some network volumes, `persist_noclobber` fails with `ENOTSUP`. The export code already handles this case in `persist_without_replacing`. Here, the error only produces a log warning and the temporary copy is dropped. Callers still use defaults and save over the original, leaving no recovery copy. The previous plain rename worked on these drives.

Add a safe fallback for filesystems that cannot support `persist_noclobber`, while keeping the protection against existing files and symlinks.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

This branch has not been deployed

No deployments
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