Skip to content

feat(cli): support API key files - #95

Merged
steipete merged 3 commits into
openclaw:mainfrom
toruvieI:feat/api-key-file
Nov 5, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
toruvieI:feat/api-key-file

Conversation

@toruvieI

@toruvieI toruvieI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #94. Add --api-key-file PATH to read a private text file in-process without exporting its contents. An explicit file overrides GOOGLE_PLACES_API_KEY; an explicit --api-key conflicts with it. Missing, unreadable, empty, nonregular, and group/other-accessible files fail without environment fallback or key disclosure.

The opened file's permissions are checked, avoiding a pathname-only mode check. File input currently fails closed on Windows because POSIX mode bits cannot verify its ACL; existing env and flag input remain available. README and API key setup docs explain these boundaries and precedence.

Validation

  • Private-file permission regressions fail against the prior PR head and pass after the fix.
  • Full Go tests, vet, build, lint, and coverage pass (92.3% overall).
  • govulncheck with the repository-pinned scanner reports no vulnerabilities.
  • Tests use synthetic keys and local HTTP servers for precedence and failure behavior. No real key was used.
  • Independent review found no actionable P0–P2 issues.

Thanks @toruvieI for the API key file implementation and CLI coverage.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds --api-key-file to load credentials directly from a text file, override inherited environment credentials, and reject explicit-key conflicts.

Example: Run goplaces --api-key-file /private/places-key search coffee with synthetic-file-key in the file and GOOGLE_PLACES_API_KEY=synthetic-env-key.

  • Before: The CLI rejects --api-key-file as an unknown flag.
  • After: The request uses synthetic-file-key without exporting it to the environment.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong built-CLI evidence and a focused, correct patch; readiness remains limited by the unresolved product decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied current-head terminal trace exercises the built CLI on darwin/arm64 through a real local HTTP transport: selected credentials reach the request header, conflicting or invalid inputs stop before HTTP, and output remains secret-free. The source preserves existing no-file behavior and changes no persisted format or stored preference.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Users cannot supply a credential file directly without placing the key in arguments or the process environment.
Reason: The feature has a concrete use case and narrow implementation, but adds a public credential-input contract that requires owner direction.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: file-based credential input is absent from main, and the new flag and precedence contract need an owner decision. The prior recovery-guidance finding is resolved; no actionable code defects remain.

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

Decision needed

  • Question: Should goplaces support --api-key-file with file-over-environment precedence and rejection of simultaneous explicit --api-key?
  • Recommendation: Accept the opt-in contract: Support the focused file-input alternative while retaining existing behavior when the flag is absent.
  • Why: This introduces a public CLI option, and neither this PR nor its linked issue records owner approval of that contract.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

The CLI parses credential inputs before constructing the shared Places and Routes client, which sends the selected key in HTTP request headers.

flowchart LR
  A[CLI arguments and environment] --> B[Global options parser]
  C[Local key file] --> D[Credential selection]
  B --> D
  D --> E[Shared API client]
  E --> F[Configured API endpoint]
Loading

Technical review

Best possible solution:

Retain the focused implementation if the CLI owner accepts the opt-in credential-file contract.

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

The capability gap is established by main's parser definition and the supplied baseline binary rejecting the new flag; it is a feature request rather than broken existing behavior.

Is this the best way to solve the issue?

The implementation keeps credential selection in the existing CLI owner and reuses the shared client's transport and redaction behavior without adding dependencies or a credential framework.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning medium; reviewed against 2a415c8e0b88.

Provenance checked

  • CLI credential selection changes intended behavior with a stated reason (f47ad81: The bootstrap provided explicit flag and environment credentials; the PR explains why an explicitly selected file should override inherited credentials.)
  • README configuration guidance keeps the original intent (docs: rewrite README to house standard #27: The README serves as a concise front door with progressive configuration guidance; the addition documents the new option and its limitations there.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main lacks file input: Main exposes APIKey through --api-key and GOOGLE_PLACES_API_KEY; Run passes that value directly to the shared client. (internal/cli/root.go:22, 2a415c8e0b88)
  • Introduced credential-selection behavior: The pinned introduction diff adds explicit-flag detection, file-over-environment selection, conflict rejection, and early failure before client construction. (internal/cli/api_key.go:11, ee9c124c34d3)
  • Earlier finding resolved: Comparison with the previously reviewed head verifies recovery actions in both file-error messages and corresponding failure expectations. (internal/cli/api_key.go:33, ee9c124c34d3)
  • Current-head shipped-entry-point proof: The contributor's terminal evidence identifies the current binary revision on darwin/arm64 and records five HTTP requests with the expected synthetic keys plus nine rejected inputs with zero requests: feat(cli): support API key files #95 (comment). The complete earlier standalone reproducer was also inspected. (ee9c124c34d3)
  • Feature ownership history: The bootstrap commit's GitHub patch establishes the original flag/environment input under steipete; subsequent CLI organization and credential-security work also belong to that feature-history contributor. (internal/cli/root.go, f47ad8108cd3)
  • Existing credential-security contract: Merged fix(security): scope API redirects and sanitize diagnostics #53 established redirect scoping and diagnostic redaction; the new file input feeds the same client and preserves those protections. (internal/places/client.go:103, 84fff29e4fd4)

Likely related people:

  • Peter Steinberger: Raw commit 48257e3 adds internal/cli/root.go:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 48257e36ffa5; files: internal/cli/root.go)

Review metrics

Metric Value Why it matters
Implementation and regression coverage Production +46 lines; tests +158 lines The small shared CLI hook is supported by distinct credential-selection, failure, and environment-preservation cases.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #94
Summary: This PR implements the canonical file-based credential-input request.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove status: ⏳ waiting on author: Current PR status label is status: ⏳ waiting on maintainer.

Label justifications:

  • P2: A useful optional credential-input improvement with limited scope and no demonstrated urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-24T11:05:00.784Z sha 9c132fd :: needs real behavior proof before merge. :: [P3] Give file-input failures an explicit recovery action
  • reviewed 2026-10-24T12:08:41.724Z sha 9c132fd :: blocked before merge. :: [P3] Give file-input failures an explicit recovery action

Reviewed October 24, 2026, 8:22 AM ET / 12:22 UTC (Revision 3).

@toruvieI

toruvieI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Built-binary offline behavior proof for --api-key-file

Tested current PR head 9c132fde7ae9b40e386373dabde217b717910547 (clean tree; binary metadata vcs.modified=false), against base 2a415c8e0b88c8f909a8a81c12a911374e776034. Both binaries built with Go 1.27.3 on darwin/arm64. No source changes.

Result: 14 head cases + 1 base case PASS. Five successful requests reached a local HTTP stub as POST /places:searchText; the stub checked the exact X-Goog-Api-Key value, not just whether a request occurred. File-only, file-over-env (LF and CRLF / equals syntax), existing env-only and explicit-key-over-env behavior all pass. Three explicit conflicts (including an empty explicit key), empty/whitespace, missing, genuinely unreadable (mode 000, non-root), directory and empty-path inputs all exit 2 with zero requests and no fallback. Base rejects the new flag (exit 80).

Only obviously synthetic fixture values were supplied. Every CLI subprocess has a freshly constructed environment, not inherited host credentials. No real credentials or Google API calls. The captured command display replaces ephemeral file paths and the local stub endpoint with neutral placeholders ($KEYFILE, $BASE_URL, etc.); it does not publish addresses or private endpoints. stdout / stderr below are actual captured CLI output; request counts and selected-key labels are asserted by the harness. Baseline usage is omitted, retaining its diagnostic.

Commands / build provenance

The source checkout is pinned to the head above; the base source is exported with git archive 2a415c8e0b88c8f909a8a81c12a911374e776034. Relative paths only:

go -C ../goplaces-api-key-file-20261024 build -o ../goplaces-api-key-file-proof-20261024/goplaces-head ./cmd/goplaces
go -C base-source build -buildvcs=false -o ../goplaces-base ./cmd/goplaces
go version -m ./goplaces-head | grep -E '^./goplaces-head:|vcs.revision=|vcs.modified='
./goplaces-head: go1.27.3
	build	vcs.revision=9c132fde7ae9b40e386373dabde217b717910547
	build	vcs.modified=false
go run public-proof.go ./goplaces-head ./goplaces-base
Captured terminal evidence: all 15 cases
CASE: base rejects file flag
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-base search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE
exit=80; HTTP requests=0; selected key=none; no key in CLI output=PASS
stderr contains: unknown flag --api-key-file (usage omitted)
CASE: file only / LF
$ env -i NO_COLOR=1  goplaces-head search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE
exit=0; HTTP requests=1; selected key=file; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: file overrides env / LF
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE
exit=0; HTTP requests=1; selected key=file; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: file overrides env / CRLF + equals syntax
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=$KEYFILE
exit=0; HTTP requests=1; selected key=file; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: env without file unchanged
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json
exit=0; HTTP requests=1; selected key=env; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: explicit key without file overrides env
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key=synthetic-flag-key
exit=0; HTTP requests=1; selected key=flag; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: explicit key conflicts with file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE --api-key=synthetic-flag-key
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key and --api-key-file cannot be used together
CASE: reverse-order equals conflict
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key=synthetic-flag-key --api-key-file=$KEYFILE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key and --api-key-file cannot be used together
CASE: explicit empty key still conflicts
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key= --api-key-file $KEYFILE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key and --api-key-file cannot be used together
CASE: empty file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=$EMPTY
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key-file is empty
CASE: whitespace-only file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=$WHITESPACE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key-file is empty
CASE: missing file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=$FIXTURES/missing
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file
CASE: unreadable file (mode 000, non-root)
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=$UNREADABLE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file
CASE: directory instead of file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=$FIXTURES
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file
CASE: empty path
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-head search coffee --base-url $BASE_URL --json --api-key-file=
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file
PASS: 14 head cases + 1 base case; 5 HTTP requests, all to the local stub; failures never fell back to env.
Reproducible standalone harness (public-proof.go, standard library only)
package main

import (
 "bytes"
 "encoding/json"
 "fmt"
 "net/http"
 "net/http/httptest"
 "os"
 "os/exec"
 "path/filepath"
 "strings"
 "sync"
)

func must(err error) { if err != nil { panic(err) } }
func main() {
 binary, err := filepath.Abs(os.Args[1]); must(err)
 dir, err := os.MkdirTemp(".", "synthetic-fixtures-"); must(err)
 defer os.RemoveAll(dir)
 dir = filepath.Clean(dir)
 keyfile := filepath.Join(dir, "key.txt")
 empty := filepath.Join(dir, "empty.txt")
 whitespace := filepath.Join(dir, "whitespace.txt")
 unreadable := filepath.Join(dir, "unreadable.txt")
 must(os.WriteFile(empty, nil, 0600))
 must(os.WriteFile(whitespace, []byte(" \r\n\t"), 0600))
 must(os.WriteFile(unreadable, []byte("synthetic-file-key"), 0000))
 defer os.Chmod(unreadable, 0600)
 if os.Geteuid() == 0 { panic("run as non-root to verify permission denial") }
 if _, err := os.ReadFile(unreadable); !os.IsPermission(err) { panic("permission-denial fixture ineffective") }
 var mu sync.Mutex
 var keys []string
 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  mu.Lock(); defer mu.Unlock()
  if r.Method != "POST" || r.URL.Path != "/places:searchText" { panic("wrong HTTP boundary") }
  keys = append(keys, r.Header.Get("X-Goog-Api-Key"))
  w.Header().Set("Content-Type", "application/json")
  _, _ = w.Write([]byte(`{"places":[{"id":"offline-proof"}]}`))
 }))
 defer server.Close()
 run := func(label, bin string, env []string, flags []string, wantCode int, wantKey, wantError string) {
  mu.Lock(); before := len(keys); mu.Unlock()
  args := append([]string{"search", "coffee", "--base-url", server.URL, "--json"}, flags...)
  cmd := exec.Command(bin, args...)
  cmd.Env = append([]string{"NO_COLOR=1"}, env...) // No inherited process environment.
  var out, stderr bytes.Buffer; cmd.Stdout = &out; cmd.Stderr = &stderr
  err := cmd.Run(); code := 0
  if err != nil { e, ok := err.(*exec.ExitError); if !ok { panic(err) }; code = e.ExitCode() }
  mu.Lock(); delta := len(keys)-before; observed := "none"
  if delta == 1 { switch keys[before] { case "synthetic-file-key": observed="file"; case "synthetic-env-key": observed="env"; case "synthetic-flag-key": observed="flag"; default: panic("unexpected key") } }
  if wantKey == "" { if delta != 0 { panic("failure made an HTTP request") } } else if delta != 1 || keys[before] != wantKey { panic("wrong selected key or request count") }
  mu.Unlock()
  if code != wantCode { panic("unexpected exit code") }
  if code == 0 {
   var result struct { Results []struct { ID string `json:"place_id"` } `json:"results"` }; must(json.Unmarshal(out.Bytes(), &result))
   if len(result.Results)!=1 || result.Results[0].ID!="offline-proof" || stderr.Len()!=0 { panic("unexpected successful CLI output") }
  } else if wantError != "" && (out.Len()!=0 || stderr.String()!=wantError+"\n") { panic("unexpected failure output") }
  for _, secret := range []string{"synthetic-file-key", "synthetic-env-key", "synthetic-flag-key"} {
   if strings.Contains(out.String()+stderr.String(),secret) { panic("key leaked to terminal output") }
  }
  // Normalize only ephemeral fixture paths and the local test endpoint.
  normalize := strings.NewReplacer(server.URL,"$BASE_URL",keyfile,"$KEYFILE",empty,"$EMPTY",whitespace,"$WHITESPACE",unreadable,"$UNREADABLE",dir,"$FIXTURES")
  fmt.Println("CASE:", label)
  fmt.Printf("$ env -i NO_COLOR=1 %s %s %s\n", strings.Join(env," "), filepath.Base(bin), normalize.Replace(strings.Join(args," ")))
  fmt.Printf("exit=%d; HTTP requests=%d; selected key=%s; no key in CLI output=PASS\n",code,delta,observed)
  if code==0 { fmt.Printf("stdout=%s\n",strings.TrimSpace(out.String())); fmt.Println("stderr=<empty>") } else if wantError!="" { fmt.Println("stdout=<empty>"); fmt.Printf("stderr=%s\n",strings.TrimSpace(stderr.String())) } else {
   if !strings.Contains(stderr.String(),"unknown flag --api-key-file") { panic("baseline did not reject new flag") }
   fmt.Println("stderr contains: unknown flag --api-key-file (usage omitted)")
  }
 }
 env := []string{"GOOGLE_PLACES_API_KEY=synthetic-env-key"}
 must(os.WriteFile(keyfile, []byte("synthetic-file-key\n"), 0600))
 if len(os.Args)>2 { base,err:=filepath.Abs(os.Args[2]);must(err);run("base rejects file flag",base,env,[]string{"--api-key-file",keyfile},80,"","") }
 run("file only / LF",binary,nil,[]string{"--api-key-file",keyfile},0,"synthetic-file-key","")
 run("file overrides env / LF",binary,env,[]string{"--api-key-file",keyfile},0,"synthetic-file-key","")
 must(os.WriteFile(keyfile, []byte("synthetic-file-key\r\n"), 0600))
 run("file overrides env / CRLF + equals syntax",binary,env,[]string{"--api-key-file="+keyfile},0,"synthetic-file-key","")
 run("env without file unchanged",binary,env,nil,0,"synthetic-env-key","")
 run("explicit key without file overrides env",binary,env,[]string{"--api-key=synthetic-flag-key"},0,"synthetic-flag-key","")
 run("explicit key conflicts with file",binary,env,[]string{"--api-key-file",keyfile,"--api-key=synthetic-flag-key"},2,"","--api-key and --api-key-file cannot be used together")
 run("reverse-order equals conflict",binary,env,[]string{"--api-key=synthetic-flag-key","--api-key-file="+keyfile},2,"","--api-key and --api-key-file cannot be used together")
 run("explicit empty key still conflicts",binary,env,[]string{"--api-key=","--api-key-file",keyfile},2,"","--api-key and --api-key-file cannot be used together")
 for _, c := range []struct{label,path,message string}{
  {"empty file",empty,"--api-key-file is empty"},
  {"whitespace-only file",whitespace,"--api-key-file is empty"},
  {"missing file",filepath.Join(dir,"missing"),"cannot read --api-key-file"},
  {"unreadable file (mode 000, non-root)",unreadable,"cannot read --api-key-file"},
  {"directory instead of file",dir,"cannot read --api-key-file"},
  {"empty path","","cannot read --api-key-file"},
 } { run(c.label,binary,env,[]string{"--api-key-file="+c.path},2,"",c.message) }
 mu.Lock(); defer mu.Unlock()
 if len(keys)!=5 { panic("unexpected total HTTP requests") }
 fmt.Println("PASS: 14 head cases + 1 base case; 5 HTTP requests, all to the local stub; failures never fell back to env.")
}

Also reran go test ./internal/cli -run TestRunAPIKeyFile -count=1 -v: both test groups and all 15 focused subcases PASS. The captured built-binary Showboat document replayed successfully with showboat verify (exit 0, explicit proof-directory workdir).

Limitations / still open: this is offline evidence of the real built CLI through the HTTP boundary, not Google authentication or production-network validation. It does not provide OS-user isolation or stop a host from exporting an existing credential. The separate P3 recovery-guidance diagnostic change and corresponding test updates remain unimplemented, and maintainer acceptance of the optional flag/precedence contract remains required. This evidence does not claim either remaining item is resolved.

PR body now links this evidence.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@toruvieI

toruvieI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

P3 recovery guidance fixed; fresh exact-head proof

Pushed ee9c124c34d37eba8e3dcd6bfbe0db58ed421810: only the two file-error messages and six exact failure expectations changed (2 files, +8/-8). No credential-selection, conflict, environment or fallback logic changed.

New diagnostics:

  • cannot read --api-key-file; select a readable plain-text API key file
  • --api-key-file is empty; populate it with an API key

Fresh validation on this head: full tests, vet, build and race tests PASS; coverage 92.5% total / 93.1% CLI (90% gate passed); gofmt and diff checks clean. The freshly built binary passes 14 head cases + 1 pinned-base case: five HTTP requests carry the expected synthetic credential header; all nine invalid/conflict cases exit 2 with zero requests/no fallback. Showboat replay PASS.

This supersedes the diagnostics portion of the earlier proof, which remains valid evidence only for 9c132fde7ae9b40e386373dabde217b717910547. To reproduce, use its standalone Go harness as diagnostics-proof.go, changing only the two exact expected diagnostic literals to the new messages above; retain every other assertion. Base remains 2a415c8e0b88c8f909a8a81c12a911374e776034.

go -C ../goplaces-api-key-file-20261024 build -o ../goplaces-api-key-file-proof-20261024/goplaces-diagnostics ./cmd/goplaces
go version -m ./goplaces-diagnostics | grep -E '^./goplaces-diagnostics:|vcs.revision=|vcs.modified='
./goplaces-diagnostics: go1.27.3
	build	vcs.revision=ee9c124c34d37eba8e3dcd6bfbe0db58ed421810
	build	vcs.modified=false
go run diagnostics-proof.go ./goplaces-diagnostics ./goplaces-base
Fresh captured terminal evidence: all 15 cases
CASE: base rejects file flag
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-base search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE
exit=80; HTTP requests=0; selected key=none; no key in CLI output=PASS
stderr contains: unknown flag --api-key-file (usage omitted)
CASE: file only / LF
$ env -i NO_COLOR=1  goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE
exit=0; HTTP requests=1; selected key=file; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: file overrides env / LF
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE
exit=0; HTTP requests=1; selected key=file; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: file overrides env / CRLF + equals syntax
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=$KEYFILE
exit=0; HTTP requests=1; selected key=file; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: env without file unchanged
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json
exit=0; HTTP requests=1; selected key=env; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: explicit key without file overrides env
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key=synthetic-flag-key
exit=0; HTTP requests=1; selected key=flag; no key in CLI output=PASS
stdout={
  "results": [
    {
      "place_id": "offline-proof"
    }
  ]
}
stderr=<empty>
CASE: explicit key conflicts with file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file $KEYFILE --api-key=synthetic-flag-key
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key and --api-key-file cannot be used together
CASE: reverse-order equals conflict
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key=synthetic-flag-key --api-key-file=$KEYFILE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key and --api-key-file cannot be used together
CASE: explicit empty key still conflicts
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key= --api-key-file $KEYFILE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key and --api-key-file cannot be used together
CASE: empty file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=$EMPTY
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key-file is empty; populate it with an API key
CASE: whitespace-only file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=$WHITESPACE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=--api-key-file is empty; populate it with an API key
CASE: missing file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=$FIXTURES/missing
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file; select a readable plain-text API key file
CASE: unreadable file (mode 000, non-root)
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=$UNREADABLE
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file; select a readable plain-text API key file
CASE: directory instead of file
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=$FIXTURES
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file; select a readable plain-text API key file
CASE: empty path
$ env -i NO_COLOR=1 GOOGLE_PLACES_API_KEY=synthetic-env-key goplaces-diagnostics search coffee --base-url $BASE_URL --json --api-key-file=
exit=2; HTTP requests=0; selected key=none; no key in CLI output=PASS
stdout=<empty>
stderr=cannot read --api-key-file; select a readable plain-text API key file
PASS: 14 head cases + 1 base case; 5 HTTP requests, all to the local stub; failures never fell back to env.
Fresh full-test / vet / build / race / coverage output (durations normalized)

Commands: go test ./... -count=1, go vet ./..., go build ./..., go test -race ./... -count=1, go test ./... -count=1 -coverprofile=PROOF/diagnostics-coverage.out, go tool cover -func=PROOF/diagnostics-coverage.out (PROOF denotes the relative proof directory).

ok  	github.com/steipete/goplaces
ok  	github.com/steipete/goplaces/cmd/goplaces
ok  	github.com/steipete/goplaces/internal/cli
ok  	github.com/steipete/goplaces/internal/places
PASS: go vet ./...
PASS: go build ./...
ok  	github.com/steipete/goplaces
ok  	github.com/steipete/goplaces/cmd/goplaces
ok  	github.com/steipete/goplaces/internal/cli
ok  	github.com/steipete/goplaces/internal/places
ok  	github.com/steipete/goplaces coverage: 90.0% of statements
ok  	github.com/steipete/goplaces/cmd/goplaces coverage: 100.0% of statements
ok  	github.com/steipete/goplaces/internal/cli coverage: 93.1% of statements
ok  	github.com/steipete/goplaces/internal/places coverage: 92.0% of statements
total coverage: 92.5%

As before: synthetic keys only, fresh CLI subprocess environments, a local HTTP stub checking POST /places:searchText and X-Goog-Api-Key, actual stdout/stderr plus asserted exit/request counts. Ephemeral fixture paths and endpoint are shown as neutral placeholders; no addresses, private names, host-private paths or private URLs are published. No Google API calls or real credentials. Offline evidence does not validate Google authentication or provide OS isolation/stop existing host exports.

Remaining product blocker: maintainer acceptance of the optional flag and precedence contract. No merge requested or performed.

PR body links the new-head evidence. No active matching review was observed after the push; requesting one fresh review.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@toruvieI

Copy link
Copy Markdown
Contributor Author

@steipete Could you confirm whether the opt-in --api-key-file contract is acceptable? ClawSweeper’s latest review found no actionable issues. GitHub now reports merge conflicts; I can resolve those once the contract is agreed.

Co-authored-by: Elfka Toruviel <aeb31988340aa87b@toruviel.online>
@steipete
steipete merged commit 27934d2 into openclaw:main Nov 5, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support --api-key-file to avoid exposing API keys through environment variables or command arguments

2 participants