mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 20:17:20 +00:00
Squash merge PR #101 after resolving dev conflicts and fixing cron GetJob snapshot race. PR CI run 26703877225 passed release-versioning, go, and web.
5.3 KiB
5.3 KiB
phase, title, status, priority, effort, dependencies
| phase | title | status | priority | effort | dependencies |
|---|---|---|---|---|---|
| 1 | Diagnose Current RapidAPI Credential Path | complete | P1 | 1.5h |
Phase 1: Diagnose Current RapidAPI Credential Path
Context Links
- Issue:
digitopvn/goclaw#74 - Related closed issue:
digitopvn/goclaw#54 - Cron payload model:
internal/store/cron_store.go - Cron run injection:
cmd/gateway_cron.go - SecureCLI lookup:
internal/tools/credentialed_exec.go
Overview
Prove the concrete failure mode before code. Current code already preserves cron credential user identity; #74 may be RapidAPI config, grant, env key, or legacy job payload.
Key Insights
CronPayload.CredentialUserIDexists and is redacted from API responses.PGCronStore.AddJobandSQLiteCronStore.AddJobstore explicit credential user identity.makeCronJobHandlerinjects that identity into cron run context.lookupCredentialedBinaryresolves per-user env throughCredentialUserIDFromContext.- No built-in RapidAPI preset exists today.
- 2026-05-29 verification:
- #54 context path is present: cron handler injects
payload.credentialUserIdbefore scheduling. - Redaction path is present: response copies clear
payload.credentialUserId. rapidapiis absent fromCLIPresets, so operators get no guidedRAPIDAPI_KEYsetup.- Credentialed exec merges base/user env but does not validate required preset env keys before process execution.
- #54 context path is present: cron handler injects
Requirements
- Functional: identify whether
rapidapiis configured, granted, and populated withRAPIDAPI_KEY. - Functional: identify if failing cron payload is legacy and lacks
credentialUserId. - Non-functional: no secret values in terminal, docs, issue comment, tests, or logs.
- Non-functional: read-only live checks unless operator explicitly approves mutation.
Architecture
Cron creation captures credential identity in payload. Cron execution injects that identity into context. Exec tool uses context to join SecureCLI per-user env. Diagnosis must trace all three links.
cron.create ctx -> payload.credentialUserId -> makeCronJobHandler ctx -> exec LookupByBinary(userID) -> RAPIDAPI_KEY env
Related Code Files
- Modify: none in this phase.
- Read:
internal/store/pg/cron_crud.go - Read:
internal/store/sqlitestore/cron_crud.go - Read:
cmd/gateway_cron.go - Read:
internal/tools/credentialed_exec.go - Read:
internal/store/pg/secure_cli.go - Read:
internal/store/sqlitestore/secure-cli.go
Implementation Steps
- Write failing characterization notes before code:
rapidapiabsent from SecureCLI registry.rapidapipresent but grant missing/disabled.- grant present but
RAPIDAPI_KEYmissing from merged env. - cron payload lacks
credentialUserId.
- Inspect local DB or live DB only with read-only commands if credentials available:
- SecureCLI binary rows for
rapidapi. - grants for the cron agent.
- sanitized env keys only; never reveal value.
- cron payload JSON for target job.
- SecureCLI binary rows for
- Add or prepare unit-level characterization tests before changing product code:
- cron handler passes
credentialUserIdthrough. - SecureCLI env merge exposes
RAPIDAPI_KEYwhen configured. - missing user env produces actionable branch in diagnostics plan.
- cron handler passes
- Decide root cause:
- config-only: document operator fix and still consider preset/logging.
- code gap: proceed Phase 2.
Todo List
- Confirm current branch contains #54 fix.
- Confirm
rapidapipreset absence. - Inspect sanitized SecureCLI config path.
- Inspect failing cron payload shape if available.
- Record exact failure class.
Success Criteria
- Root cause class documented with code/file evidence.
- No secret material displayed or persisted.
- Tests-before list finalized for Phase 2.
Diagnosis Result
Root cause class: product support gap plus weak diagnostics, not missing cron identity plumbing.
Code evidence:
cmd/gateway_cron.goinjectsstore.WithCredentialUserIDwhenjob.Payload.CredentialUserIDis present.internal/store/cron_store.goredactsCredentialUserIDfrom response-safe cron jobs.internal/tools/credentialed_exec.gousesstore.CredentialUserIDFromContext(ctx)forLookupByBinary.internal/tools/credential_presets.gohas norapidapipreset.internal/tools/credentialed_exec.goreturns downstream CLI output when env is empty, so a RapidAPI failure surfaces as rawRAPIDAPI_KEY requiredinstead of a GoClaw credential diagnostic.
Live DB inspection was not run in this phase because no operator-approved credentialed environment or target cron job was provided. Phase 2 proceeds with code-level regression coverage for the confirmed local gap.
Risk Assessment
- Risk: live DB access reveals secrets. Mitigation: query key names/sanitized responses only.
- Risk: legacy cron payload mistaken for current bug. Mitigation: compare job creation time against fix version.
- Risk: RapidAPI CLI command shape unknown. Mitigation: treat smoke command as operator-provided until verified.
Security Considerations
- Never use
printenv,env, or CLI debug flags to prove secret presence. - Validate by CLI success/failure and sanitized env key metadata.
Next Steps
- If root cause is missing preset or diagnostics, Phase 2.
- If root cause is stale cron payload only, Phase 3 documents remediation and issue reply.