Skip to content

feat(drive): add conditional file replacement - #929

Merged
steipete merged 1 commit into
openclaw:mainfrom
karstenevers:feat/drive-upload-conditional-replace
Jul 27, 2026
Merged

feat(drive): add conditional file replacement#929
steipete merged 1 commit into
openclaw:mainfrom
karstenevers:feat/drive-upload-conditional-replace

Conversation

@karstenevers

@karstenevers karstenevers commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Add opt-in atomic conflict protection to gog drive upload --replace.

Callers that previously read a Drive file can pass its version:

gog drive upload file.pdf --replace FILE_ID --if-version VERSION

Existing replacement remains available and unchanged:

gog drive upload file.pdf --replace FILE_ID

Motivation

Replacement previously performed a metadata read followed by an unconditional media update. If another collaborator changed the file between those requests, the newer content could be overwritten.

A separate version comparison is insufficient because the file can still change after the comparison and before the update. The final media update must carry an atomic server-side precondition.

Implementation

Conditional replacement:

  1. Reads the current Drive version and ETag.
  2. Fails closed if either value is missing.
  3. Compares the current version with --if-version.
  4. Sends the retrieved ETag as If-Match on one media Files.Update request.
  5. Reports HTTP 412 as a conflict without retrying or falling back to an unconditional update.

Drive v3 does not expose the file ETag needed for this precondition. Therefore, only the opt-in conditional path uses Drive v2, which exposes both version and etag. Normal uploads and unconditional replacement remain on Drive v3.

The Drive v2 service is created through gog’s existing authenticated Google API service factory. OAuth tokens are not exported or exposed, and no second authentication implementation is introduced.

The Drive v2 media update uses HTTP PUT rather than the v3 PATCH, but the If-Match precondition is attached to the final media write and closes the check/write race atomically.

Design tradeoff

Drive v3 does not expose the file ETag needed for an atomic If-Match precondition. This implementation therefore uses Drive v2 only for the opt-in conditional replacement path.

Google currently documents Drive v2 without an announced sunset date, but recommends v3 for general use. If v2 is deprecated later, this path will need an alternative atomic precondition mechanism.

The v2 dependency is isolated from normal uploads and unconditional v3 replacement. Conditional replacement also fails closed rather than falling back to an unsafe update.

Conflict behavior

  • A version mismatch stops before the media update and reports a conflict.
  • A missing version or ETag fails closed and performs no update.
  • HTTP 412 reports that the file changed after metadata was read and tells the caller to re-read and reapply the edit.
  • Conditional replacement is attempted once.
  • It never retries or falls back to an unconditional update.
  • Existing --replace behavior remains unconditional when --if-version is absent.

Backward compatibility

The new behavior is opt-in. Existing callers can continue using:

gog drive upload file.pdf --replace FILE_ID

without supplying a version and without any change to current output or replacement behavior.

Tests

Added httptest coverage for:

  • existing unconditional replacement compatibility;
  • flag parsing and validation;
  • incompatible option combinations;
  • conditional dry-run output;
  • matching versions and exact If-Match propagation;
  • stale versions stopping before the update;
  • HTTP 412 conflicts without retry or success output;
  • missing version and ETag fail-closed behavior;
  • the existing authentication service boundary.

Validation completed:

  • targeted Drive upload and service tests;
  • make fmt;
  • make test;
  • make ci.

make ci completed successfully with:

  • lint: 0 issues;
  • all Go tests passing;
  • all Node tests passing;
  • generated command documentation passing;
  • documentation site, link, and coverage checks passing.

Credential-backed Drive evidence

PR head 779c18a6a14e681b25c9ae7081c9be22214121fb was validated against Google Drive on July 19, 2026 using the local fork and one disposable text file.

  • A conditional replacement with the matching expected version succeeded and preserved the file ID and name.
  • Drive advanced the file version from 3 to 6, and the downloaded replacement matched the local payload byte-for-byte.
  • A second replacement using the stale expected version 3 reported a conflict against current version 6.
  • After the stale conflict, the Drive version, modification time, size, and downloaded SHA-256 remained unchanged; the rejected payload was not applied.
  • The focused httptest suite also passed for exact If-Match propagation, HTTP 412 conflict handling, single-attempt media updates, missing-precondition fail-closed behavior, and prevention of unconditional retry or fallback.
  • The disposable Drive file was moved to Trash after validation.

Drive version values are monotonic but not necessarily consecutive. Google documents that the counter reflects every server-side change, including changes not visible to the user. The conditional implementation relies only on exact equality and does not assume that a successful replacement increments the version by one.

The account and Drive file ID are redacted from the posted evidence. gog’s existing authentication boundary was used; no OAuth token, client secret, authorization code, or credential material was printed or recorded.

References

@karstenevers

Copy link
Copy Markdown
Contributor Author

Hi! I opened this as a draft to get early feedback on the API approach.

The main design question is using Drive v2 only for conditional replacement because Drive v3 does not expose the file ETag needed for an atomic If-Match precondition. Existing uploads and unconditional replacement remain on Drive v3, and the conditional path fails closed if it cannot obtain the required precondition material.

Would this limited use of Drive v2 be acceptable upstream, or would you prefer a different direction? If the approach looks reasonable, I’ll mark the PR ready for full review.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 1:40 PM ET / 17:40 UTC.

ClawSweeper review

What this changes

This PR adds gog drive upload --replace --if-version, which conditionally replaces a Drive file only when its current version matches and otherwise reports a conflict without an unconditional fallback.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open. It adds a bounded opt-in Drive write-safety feature with credible real-Drive proof and no definite patch defect found, but landing it still requires an explicit maintainer decision to support the isolated Drive v2 dependency used for atomic ETag preconditions.

Priority: P2
Reviewed head: bdd8abd2305c3425c284108772d0fd941b0099ed
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR has strong real behavior proof and focused validation; the remaining merge blocker is a maintainer choice about the public Drive v2 support boundary.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR contains redacted terminal evidence from a real Drive account showing matching-version success and stale-version rejection, while focused httptest coverage demonstrates the deterministic HTTP 412 race and no-retry path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR contains redacted terminal evidence from a real Drive account showing matching-version success and stale-version rejection, while focused httptest coverage demonstrates the deterministic HTTP 412 race and no-retry path.
Evidence reviewed 6 items Current main does not yet provide the feature: The checked current-main Drive upload implementation exposes --replace but no --if-version flag or guarded replacement branch, so the central requested behavior is not already implemented on main.
Bounded implementation path: The PR introduces the public --if-version flag and routes only that opt-in path through Drive v2, while preserving the existing v3 unconditional replacement path when the flag is absent.
Single-attempt protection: The patch adds a request-context opt-out for retry handling so conditional media writes do not retry a potentially ambiguous result or fall back to an unconditional update.
Findings None None.
Security None None.

How this fits together

The Drive upload command converts a local file and CLI flags into Google Drive API writes. Normal replacement continues through Drive v3, while the new conditional path obtains version and ETag metadata through Drive v2 before issuing one guarded media update.

flowchart LR
  A[Local file and upload flags] --> B[Drive upload command]
  B --> C{Expected version supplied?}
  C -->|No| D[Drive v3 replacement]
  C -->|Yes| E[Drive v2 metadata read]
  E --> F{Version and ETag valid?}
  F -->|Yes| G[Single If-Match media update]
  F -->|No| H[Conflict or fail-closed error]
  G --> I[Upload result or HTTP 412 conflict]
Loading

Decision needed

Question Recommendation
Should gogcli support the new public --if-version Drive replacement contract by retaining a narrowly scoped Drive v2 dependency for ETag-based atomic writes? Accept the isolated Drive v2 path: Keep Drive v2 limited to opt-in conditional replacement, preserve unconditional Drive v3 replacement, and document that unavailable preconditions fail closed.

Why: The patch is technically bounded and proven, but source tests cannot choose the repository's long-term support policy for an older Google Drive API surface or the intended user experience when that API becomes unavailable.

Before merge

  • Resolve merge risk (P1) - The new public flag depends on Google Drive v2 continuing to be available for the ETag metadata and guarded media-update path; callers who opt in will fail closed if that path cannot obtain valid precondition material.
  • Resolve merge risk (P1) - The conditional path intentionally converts ambiguous retryable media-write outcomes into a single failed attempt rather than retrying, so maintainers should explicitly accept this conflict-safe operational tradeoff.
  • Complete next step (P2) - No concrete code repair is indicated; a maintainer must decide whether the new Drive v2 API support boundary is acceptable before this proven feature can merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 14 files changed; 650 added, 11 removed The feature spans public CLI parsing, Google service construction, retry semantics, generated command documentation, and focused tests.
Public command contract 1 new upload flag --if-version adds an opt-in behavior with a distinct failure mode that scripts and operators may rely on.

Merge-risk options

Maintainer options:

  1. Accept the bounded v2 compatibility tradeoff (recommended)
    Merge with Drive v2 restricted to callers who explicitly pass --if-version, preserving current v3 replacement behavior for every existing invocation.
  2. Pause for a v3-only direction
    Keep this PR open until maintainers decide whether conditional replacement must avoid the Drive v2 dependency entirely.

Technical review

Best possible solution:

Retain the opt-in v3-compatible default and land the guarded v2 path only if maintainers explicitly accept Drive v2 as the narrowly scoped atomic-precondition mechanism, with the documented fail-closed behavior and regression coverage preserved.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR proposes a new opt-in Drive write mode, not a failure of an established current-main behavior. The contributor did provide a high-confidence live validation path for the proposed success and stale-version outcomes.

Is this the best way to solve the issue?

Unclear pending maintainer policy direction. The ETag If-Match design is the narrowest demonstrated way to close the check/write race, but whether the isolated Drive v2 dependency is acceptable is a product and support-boundary choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fd3d054499f3.

Labels

Label justifications:

  • P2: This is a bounded opt-in improvement to Drive replacement safety rather than an urgent regression.
  • merge-risk: 🚨 compatibility: The PR adds a public CLI flag and alternate Drive API route that must preserve existing unconditional replacement behavior and remain supportable across upgrades.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR contains redacted terminal evidence from a real Drive account showing matching-version success and stale-version rejection, while focused httptest coverage demonstrates the deterministic HTTP 412 race and no-retry path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR contains redacted terminal evidence from a real Drive account showing matching-version success and stale-version rejection, while focused httptest coverage demonstrates the deterministic HTTP 412 race and no-retry path.

Evidence

What I checked:

  • Current main does not yet provide the feature: The checked current-main Drive upload implementation exposes --replace but no --if-version flag or guarded replacement branch, so the central requested behavior is not already implemented on main. (internal/cmd/drive_upload.go:3, fd3d054499f3)
  • Bounded implementation path: The PR introduces the public --if-version flag and routes only that opt-in path through Drive v2, while preserving the existing v3 unconditional replacement path when the flag is absent. (internal/cmd/drive_upload.go:26, bdd8abd2305c)
  • Single-attempt protection: The patch adds a request-context opt-out for retry handling so conditional media writes do not retry a potentially ambiguous result or fall back to an unconditional update. (internal/googleapi/transport.go:25, bdd8abd2305c)
  • Real behavior proof: The PR discussion includes redacted credential-backed Drive output showing a matching-version replacement preserves file identity and payload integrity, followed by a stale-version rejection that leaves the remote file unchanged; focused tests cover the narrower HTTP 412 race and single-attempt behavior. (internal/cmd/drive_upload_replace_test.go:328, bdd8abd2305c)
  • Release status: The supplied release context identifies v0.34.1 as the latest release, and current-main CHANGELOG.md lists that version without this feature; the PR branch instead prepares an unreleased 0.34.2 entry. (CHANGELOG.md:1, fd3d054499f3)
  • Recent feature-history signal: The current PR head was force-pushed as commit bdd8abd2305c3425c284108772d0fd941b0099ed, authored by steipete with Karsten Evers credited as co-author, which is a strong signal that the proposed direction has received direct area involvement but is not a released main-branch implementation. (internal/cmd/drive_upload.go:26, bdd8abd2305c)

Likely related people:

  • steipete: The current PR head is authored by steipete and carries the final integrated implementation of the Drive CLI and transport changes. (role: recent area contributor; confidence: high; commits: bdd8abd2305c; files: internal/cmd/drive_upload.go, internal/googleapi/transport.go, internal/googleapi/drive.go)
  • Karsten Evers: The current commit credits Karsten Evers as co-author, and the PR discussion provides the design rationale and credential-backed validation for the conditional replacement behavior. (role: feature contributor; confidence: medium; commits: bdd8abd2305c; files: internal/cmd/drive_upload_replace_test.go, docs/commands/gog-drive-upload.md)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain an explicit maintainer decision on the narrowly scoped Drive v2 dependency before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-07-18T20:45:59.141Z sha 00543aa :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-19T05:09:11.285Z sha 779c18a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-19T05:33:17.253Z sha 779c18a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-19T16:28:41.709Z sha 779c18a :: needs maintainer review before merge. :: none

@karstenevers

Copy link
Copy Markdown
Contributor Author

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(drive): add conditional file replacement This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

Updated the conditional replacement path in 779c18a6 to guarantee that the media write is attempted exactly once.

The conditional update now:

  • opts out of gog's 429, 5xx, and authentication-refresh retries;
  • uses one multipart request, preventing large files from switching to the generated client's retrying resumable uploader;
  • preserves normal retry behavior for the preceding metadata GET;
  • never retries or falls back to an unconditional update.

The new tests verify that:

  • a metadata GET returning 429 is retried normally;
  • a conditional update returning an ambiguous 500 response is attempted exactly once and never reports success;
  • media larger than 16 MiB still produces one multipart update request;
  • the If-Match precondition remains attached to the final write.

make test and the complete make ci gate pass, with lint reporting 0 issues.

@karstenevers

Copy link
Copy Markdown
Contributor Author

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 4:45 PM ET / 20:45 UTC.

Summary The PR adds gog drive upload --replace --if-version to conditionally replace a Drive file with a version check and atomic ETag precondition.

Reproducibility: not applicable. as a current-main bug reproduction: this PR proposes a new opt-in conditional write mode rather than repairing a documented existing contract.

Review metrics: 2 noteworthy metrics.

  • Patch surface: 11 files affected; 459 added, 8 removed. The feature crosses CLI parsing, runtime service wiring, Google API construction, generated command docs, and focused tests.
  • New public option: 1 CLI flag added. --if-version creates an opt-in user-facing write contract that needs maintainer approval.

Merge readiness Overall: 🧂 unranked krab Proof: 🧂 unranked krab Patch quality: 🦐 gold shrimp Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Obtain maintainer direction on the isolated Drive v2 dependency.
  • [P1] Add redacted real Drive evidence for matching-version success and stale-version conflict behavior.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR describes tests and CI but provides no after-fix real Drive run; before merge, add redacted terminal output or logs showing a successful matching-version replacement and a stale-version HTTP 412 conflict. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The opt-in path depends on Drive v2 remaining available and enabled for consumers; when it cannot obtain v2 precondition data, the proposed behavior deliberately fails closed.
  • [P1] There is no redacted live Drive run showing both a successful matching-version update and a stale-version conflict before this external PR is ready to merge.

Maintainer options:

  1. Decide the mitigation before merge
    If maintainers sponsor the Drive v2 tradeoff, keep the behavior opt-in, document the fail-closed operational requirement, and add redacted live Drive proof for successful and conflicting replacements.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The draft explicitly asks whether the limited Drive v2 strategy is acceptable; that support-policy choice cannot be resolved by an automated repair.

Maintainer decision needed

  • Question: Should gogcli support opt-in conditional Drive replacement by retaining a narrowly scoped Drive v2 dependency for ETag-based If-Match writes?

  • Rationale: The patch intentionally adds a public CLI capability and an older Google API-version dependency; source-level tests cannot determine the project’s long-term support policy for that dependency.

  • Likely owner: steipete — This decision spans the repository’s Drive CLI contract and Google API service boundary.

  • Options:

    • Accept the isolated v2 path (recommended): Keep Drive v2 limited to --if-version replacement, with the proposed fail-closed behavior and explicit operational documentation.
    • Require a v3-only design: Decline the v2 dependency and ask for a conditional-write design that stays on the supported Drive v3 client surface.

Security Cleared: The diff adds no new secret-export, package-install, workflow, or third-party execution path and routes Drive v2 through the existing authenticated service factory.

Review details
Label changes
Evidence reviewed
What the crustacean ranks mean
How this review workflow works

Regarding the requested behavior evidence, the automated tests now distinguish the two conflict cases:

  • An already-stale caller version is detected before the media update, so no update request is made.
  • HTTP 412 represents the narrower race where the file changes after the metadata GET but before the conditional update. That race is exercised deterministically with httptest, including verification that the request is not retried and no unconditional fallback occurs.

No credential-backed Drive run has been performed for this draft yet. A redacted live run can demonstrate the matching-version success path and the already-stale-version path, but reliably inducing the post-GET HTTP 412 race requires coordinating a concurrent write and is better covered deterministically.

Would the maintainers prefer live redacted success/stale-version evidence before deciding whether the isolated Drive v2 conditional path is acceptable, or should the v2 design direction be resolved first?

@karstenevers
karstenevers marked this pull request as ready for review July 19, 2026 05:30
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Jul 19, 2026
@karstenevers

Copy link
Copy Markdown
Contributor Author

Credential-backed Drive evidence

Validated PR head 779c18a6a14e681b25c9ae7081c9be22214121fb against Google Drive using the local fork and one disposable text file.

The account and Drive file ID are redacted below. Nonessential JSON fields are omitted.

Matching-version replacement

The initial upload was downloaded and verified against the local baseline:

baseline local SHA-256:       1a9a57d9421de91d6c1133889d2a2a242d53ac7b9fe7746a7b18dc71bc533f0d
baseline downloaded SHA-256:  1a9a57d9421de91d6c1133889d2a2a242d53ac7b9fe7746a7b18dc71bc533f0d
Drive version before replacement: 3

The conditional dry run represented the expected precondition:

{
  "dry_run": true,
  "op": "drive.upload",
  "request": {
    "replace_file_id": "<FILE_ID>",
    "if_version": 3,
    "size": 79,
    "mime_type": "text/plain"
  }
}

The matching conditional replacement succeeded:

$ ./bin/gog --account <ACCOUNT> drive upload matching-replacement.txt \
    --replace <FILE_ID> --if-version 3 --json --no-input

exit: 0
result: same file ID and name, size 79
Drive version after replacement: 6

The downloaded replacement matched the local payload:

replacement local SHA-256:       852336256b8f4cef133171015c2300407acb974356065f6843676a7b64944e82
replacement downloaded SHA-256:  852336256b8f4cef133171015c2300407acb974356065f6843676a7b64944e82

Drive version values are monotonic but not necessarily consecutive. Google documents that the counter reflects every server-side change, including changes not visible to the user. The conditional implementation relies only on exact equality and does not assume that a successful replacement increments the version by one.

Already-stale version

After Drive had advanced to version 6, the replacement was attempted again using stale expected version 3 and a different sentinel payload:

$ ./bin/gog --account <ACCOUNT> drive upload stale-attempt.txt \
    --replace <FILE_ID> --if-version 3 --json --no-input

conditional Drive replacement conflict for file <FILE_ID>: expected version 3, current version is 6; re-read the file and reapply your edit
exit: 1

Post-conflict verification:

Drive version before stale attempt: 6
Drive version after stale attempt:  6
modifiedTime: unchanged
size:         unchanged at 79 bytes

successful replacement SHA-256: 852336256b8f4cef133171015c2300407acb974356065f6843676a7b64944e82
download after stale conflict:   852336256b8f4cef133171015c2300407acb974356065f6843676a7b64944e82
rejected sentinel SHA-256:       3d27370bd42d6b0de44bc21d37af036d99836b8365f96f880783e02df4aa7b23

The stale payload was not applied.

Atomic-race and retry validation

The focused local suite was rerun using httptest:

PASS TestDriveUpload_IfVersionValidationAndDryRun
PASS TestDriveUpload_ConditionalReplace_MatchingVersionUsesETag
PASS TestDriveUpload_ConditionalReplace_StaleVersionStopsBeforePatch
PASS TestDriveUpload_ConditionalReplace_PreconditionFailureIsConflict
PASS TestDriveUpload_ConditionalReplace_RetryableFailureIsNotRetried
PASS TestDriveUpload_ConditionalReplace_LargeMediaUsesSingleRequest
PASS TestDriveUpload_ConditionalReplace_MissingPreconditionMaterialFailsClosed

ok github.com/steipete/gogcli/internal/cmd

These cases verify the exact If-Match header, HTTP 412 conflict mapping, one media-update attempt, no unconditional fallback, and fail-closed handling when version or ETag material is missing.

Cleanup and credential handling

The disposable file was moved to Drive Trash:

{
  "deleted": false,
  "id": "<FILE_ID>",
  "trashed": true
}

The repository remained clean. gog's existing authentication boundary was used; no OAuth token, client secret, authorization code, or credential material was printed or captured.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 19, 2026
Co-authored-by: Karsten Evers <50057690+karstenevers@users.noreply.github.com>
@steipete
steipete force-pushed the feat/drive-upload-conditional-replace branch from 779c18a to bdd8abd Compare July 27, 2026 17:36
@steipete

Copy link
Copy Markdown
Collaborator

Maintainer decision accepted: gog supports the narrowly scoped Drive v2 ETag path for opt-in conditional replacement. Existing and unconditional uploads remain on Drive v3; the conditional write fails closed if precondition material is unavailable and never retries or falls back to an unconditional update.

Landed candidate: bdd8abd2305c3425c284108772d0fd941b0099ed

Proof on that exact candidate:

  • focused Drive upload and Google API transport tests
  • make fmt-check
  • make test (all Go packages and 11 Node tests)
  • AutoReview: clean, no accepted/actionable findings (confidence 0.98)
  • built-CLI source-blind contract: conditional dry-run includes if_version; unconditional replacement omits it; missing --replace and non-positive versions fail before authentication or any write
  • contributor live Drive proof remains applicable to the unchanged runtime patch: matching-version replacement preserved the file ID and produced byte-identical downloaded content; a stale version was rejected without changing version, metadata, size, or content; the disposable file was trashed
  • exact-head CI: https://github.com/openclaw/gogcli/actions/runs/30289999365
  • exact-head Docker: https://github.com/openclaw/gogcli/actions/runs/30290000619

The commit preserves contributor credit with Co-authored-by: Karsten Evers <50057690+karstenevers@users.noreply.github.com> and the changelog thanks @karstenevers.

@steipete
steipete merged commit 1b26124 into openclaw:main Jul 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants