Skip to content

orbit copy with trailing slash on destination silently creates a regular file #110

Closed

Description

@saworbit

Summary

When the destination argument to orbit copy or orbit plan ends in a trailing path separator (e.g. out/ or out\), Orbit silently normalizes it away and creates a regular file at that path. A trailing separator is a well-established user signal (POSIX, rsync, cp) that the destination is intended to be a directory, so this is surprising given the "exact target path" contract.

Repro

Windows, orbit 0.1.0-alpha.0 on branch codex/single-file-copy (commit 2abf672).

$vibe = 'C:\tmp\vibe'
Remove-Item -Recurse -Force $vibe -ErrorAction SilentlyContinue
New-Item -ItemType Directory $vibe | Out-Null
"hello" | Set-Content -Encoding ascii "$vibe\src.txt"

orbit.exe copy "$vibe\src.txt" "$vibe\new_dir\"

Observed output:

Copied \\?\C:\tmp\vibe\src.txt -> \\?\C:\tmp\vibe\new_dir (7 bytes, hash verified)

A regular file new_dir (no trailing separator) is created, with no warning or acknowledgement that the trailing separator was dropped.

plan behaves the same way:

orbit.exe plan "$vibe\src.txt" "$vibe\plan_slash\" --json
{"schema_version":1,"event":"plan_entry","data":{...,"destination":{"encoding":"utf8","value":"\\\\?\\C:\\tmp\\vibe\\plan_slash"},...,"kind":"file","disposition":"copy","reason":"destination does not exist",...}}

The planned entry's destination has the trailing separator removed and kind is file.

Expected

One of the following, in order of strictness:

  1. Refuse when the destination argument ends with a trailing path separator — a trailing separator is a directory signal and copy only accepts a single-file destination today. Exit 3 with a clear message would match the existing design that rejects ambiguous destinations.
  2. Preserve the user's input verbatim and refuse if the resulting path refers to anything other than an exact non-existent target.

Silent normalization to a file is the behavior most likely to surprise users coming from cp, rsync, or shell conventions.

Notes

  • On Windows this falls out of std::path::absolute → GetFullPathNameW, which strips trailing separators from ordinary paths. On Linux the trailing separator is retained in the Path, so the behavior may differ between platforms today.
  • Caught during fundamentals/vibe testing of the copy flow.

Activity

  1. added
    bug
    on Oct 28, 2026
  2. saworbit commented on Oct 28, 2026

    @saworbit
    OwnerAuthor

    Fixed in d9eb186 on PR #113. resolve_endpoints now rejects a destination that ends with / or \ on the raw input, before Windows GetFullPathNameW can drop it. New error code destination_has_trailing_separator, exit 3. Covered by a paths unit test and a copy integration test. CHANGELOG updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions