Skip to content

fix(engine): refuse unusable field photo destinations - #2185

Closed
giswqs wants to merge 1 commit into
mainfrom
sweep/engine-quality-2026-11-15
Closed

giswqs wants to merge 1 commit into
mainfrom
sweep/engine-quality-2026-11-15

Conversation

@giswqs

@giswqs giswqs commented Nov 15, 2026

Copy link
Copy Markdown
Member

Summary

Bring Back now refuses a photo destination whose metadata cannot be read, before applying edits or writing photos. Previously, a file named <area> photos where the destination directory should be caused the filename-selection loop to try numbered candidates forever, freezing the command.

The regression creates that destination conflict, bounds completion with a channel deadline, and checks that the project and existing file remain unchanged.

Release sweep finding: #2029 (comment)

Testing

  • Passed git diff --check, cargo fmt --all --check and direct rustfmt verification.
  • Targeted regression started with GDAL 3.13.3 in a local environment; still compiling when submitted.
  • Long-running tests and full workspace validation are pending, submitted without waiting as requested. CI must pass before merge.

UI evidence

No visible UI change; this fixes the engine's failed-file path.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b383ef46-513c-4169-97c8-44aa62b9dbfb
Commits

Reviewing files that changed from the base of the PR and between ce40749 and 9163762.

Files selected for processing: 1

  • crates/engine/src/cmd/field.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

break;
}
_ => path = dir.join(format!("{n}-{name}")),
Err(e) => return Err(format!("{}: {e}; no photo was brought back", path.display())),

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.

Nit (documentation, not a bug): the fix is correct. Any metadata error other than NotFound now refuses the package before any edit. The doc comment on bring_back (around lines 435-441) still describes only the "taken by other bytes" case, so it doesn't mention this refusal. Suggest one sentence there, e.g. "A folder that can't be used (a file is in its place, say) refuses the whole package before any edit is made, and says which path." Note this refuses the whole package for one photo whose path fails, rather than leaving that photo out and counting it as the non-plain-name case does. That is consistent with "unusable results are errors", so I'm not asking for a change, just making the choice visible.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. The fix is correct. The candidate-name loop in bring_back (crates/engine/src/cmd/field.rs:531-541) used to send every metadata error other than NotFound to the next candidate. When a file sits where the photo folder should be, every candidate fails with ENOTDIR, so the loop never ends. The new Err(e) arm returns before sync_area, take_new_fields, or any photo write, so a refused run leaves the project and disk untouched. Confidence: high.

Security: None found. The diff adds no new input handling beyond the existing plain_file check.

Performance: None found. The change only affects the error path.

Quality:

  • The bring_back doc comment (lines 435-441) still describes only the "taken by other bytes" case and doesn't mention the new refusal. This is a nit. I posted it inline on line 538 with the suggested wording. Confidence: high.
  • The regression test (field.rs ~1246-1275) runs the command on a spawned thread and waits up to 5 s. If the bug comes back, that thread keeps spinning after the assertion fails. The process still exits when the suite finishes, so this is a minor CPU cost during the run, not a hang. Confidence: medium.

AGENTS.md: Compliant. The diff adds no unwrap, expect, or panic to non-test code. The fix has a regression test. The refusal is an error that names the path, so it is not silent. The test's timer wait carries // test-wait:. The bring-back command runs on the UI thread, as its doc comment already says, and this diff doesn't change that. I checked the other candidate loops in field.rs (lines 140, 364, 667), connections.rs:852, and apps/rustgis-mobile/src/ios.rs:267. They use exists(), which returns false on error and ends the loop, so none of them has the same hang.

Not verified: The PR says the targeted test was still compiling and the full CI had not run when submitted. I could not compile or run it here, so the test passing and failing on the old code is unconfirmed. Session being Send for the spawned thread is likely, since other engine tests move run values into threads, but that is also unconfirmed.

Earlier concerns: There were no prior review threads, so I left none alone.

Change size

Compared with main (merge base ce40749 to PR head 9163762).

Measure Value
Files changed 1 (added 0, modified 1, removed 0, renamed 0)
Size before 72.9 KB
Size after 75.0 KB
Total size change +2.1 KB
Path Before After Change
crates/engine/src/cmd/field.rs 72.9 KB 75.0 KB +2.1 KB

@giswqs

giswqs commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Superseded by the combined engine correctness PR #2201.

@giswqs giswqs closed this Nov 15, 2026
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