Skip to content

core: dedupe approval not-found handling#60932

Merged
gumadeiras merged 5 commits into
mainfrom
codex/approval-error-dedupe
Apr 4, 2026
Merged

core: dedupe approval not-found handling#60932
gumadeiras merged 5 commits into
mainfrom
codex/approval-error-dedupe

Conversation

@gumadeiras

Copy link
Copy Markdown
Member

Summary

  • Problem: approval-not-found detection was duplicated in core /approve handling and the Telegram resolver.
  • Why it matters: duplicated gateway-error parsing drifts easily and makes future approval-path fixes more expensive.
  • What changed: moved approval-not-found classification into one shared infra helper and updated the core + Telegram callers to use it.
  • What did NOT change (scope boundary): No Matrix UX changes, no approval prompt rendering changes, no protocol changes.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: the same approval-not-found error decoding logic lived in multiple places instead of one shared helper.
  • Missing detection / guardrail: no shared utility enforced consistent handling across approval submitters.
  • Contributing context (if known): approval resolution spans legacy and structured gateway errors, so drift is easy when each caller hand-rolls the parser.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: existing approval submitter tests plus shared helper call sites
  • Scenario the test should lock in: structured and legacy unknown/expired approval errors are classified consistently across callers.
  • Why this is the smallest reliable guardrail: the behavior is pure error classification with thin caller wiring.
  • Existing test that already covers this (if any): Telegram approval resolver coverage exercises not-found fallback behavior.
  • If no new test is added, why not: this split keeps the already-covered shared-core extraction small and behavior-preserving.

User-visible / Behavior Changes

  • None

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node/pnpm dev env
  • Model/provider: N/A
  • Integration/channel (if any): core approval routing + Telegram approval resolver
  • Relevant config (redacted): N/A

Steps

  1. Trigger an approval resolution path that receives a structured or legacy unknown/expired approval error.
  2. Observe fallback/handling in the caller.

Expected

  • Callers classify the error consistently using one shared helper.

Actual

  • Fixed by this PR.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: build passes; static checks pass; shared helper matches the prior caller behavior.
  • Edge cases checked: structured INVALID_REQUEST + APPROVAL_NOT_FOUND, direct APPROVAL_NOT_FOUND, legacy message-text fallback.
  • What you did not verify: full targeted Vitest reruns in this local environment beyond prior focused coverage.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: subtle mismatch with one callers previous local implementation.
    • Mitigation: the shared helper is a direct extraction of the existing logic and build/static checks passed.

Copilot AI review requested due to automatic review settings April 4, 2026 15:50
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Apr 4, 2026
@greptile-apps

greptile-apps Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR deduplicates the isApprovalNotFoundError classification logic that previously existed independently in src/auto-reply/reply/commands-approve.ts and extensions/telegram/src/exec-approval-resolver.ts, consolidating it into a new src/infra/approval-errors.ts helper and re-exporting it from openclaw/plugin-sdk/infra-runtime. The extraction is faithful — the hardcoded string constants match the ErrorCodes enum values exactly — and call-site behavior is unchanged.

  • isApprovalNotFoundError is now part of the public openclaw/plugin-sdk/infra-runtime surface but docs/.generated/plugin-sdk-api-baseline.sha256 was not regenerated; pnpm plugin-sdk:api:check (enforced in workflow-sanity.yml) will fail in CI. Run pnpm plugin-sdk:api:gen and commit the updated hash file.

Confidence Score: 4/5

Safe to merge after regenerating the Plugin SDK API baseline hash; the logic change itself is correct and behavior-preserving.

One P1 finding: the public Plugin SDK surface was expanded but docs/.generated/plugin-sdk-api-baseline.sha256 was not updated, which will break the pnpm plugin-sdk:api:check CI gate. All other aspects of the refactor are correct.

src/plugin-sdk/infra-runtime.ts — needs accompanying plugin-sdk-api-baseline.sha256 regeneration

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/plugin-sdk/infra-runtime.ts
Line: 17

Comment:
**Missing Plugin SDK API baseline update**

`isApprovalNotFoundError` is now re-exported from the public `openclaw/plugin-sdk/infra-runtime` subpath, which expands the tracked Plugin SDK surface. The `docs/.generated/plugin-sdk-api-baseline.sha256` hash file was not regenerated, so `pnpm plugin-sdk:api:check` (which runs in `workflow-sanity.yml`) will fail in CI.

Per the repo guidelines, after changing the public Plugin SDK surface you must run `pnpm plugin-sdk:api:gen` and commit the updated `.sha256` file alongside the change.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "core: dedupe approval not-found handling" | Re-trigger Greptile

Comment thread src/plugin-sdk/infra-runtime.ts Outdated

Copilot AI left a comment

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.

Pull request overview

This PR removes duplicated “approval not found” error classification logic by extracting it into a shared infra helper, then wiring both the core /approve handler and the Telegram approval resolver to use that helper. This reduces drift risk between approval submitters that need to interpret both structured gateway errors and legacy message-text errors.

Changes:

  • Added isApprovalNotFoundError() in a new shared module (src/infra/approval-errors.ts).
  • Updated core /approve handling to use the shared helper instead of in-file parsing.
  • Updated the Telegram exec approval resolver to import the shared helper via the plugin SDK infra runtime barrel.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/plugin-sdk/infra-runtime.ts Re-exports the shared approval error helper for plugin/extension consumers.
src/infra/approval-errors.ts Introduces centralized detection for “approval not found” across structured + legacy error shapes.
src/auto-reply/reply/commands-approve.ts Removes duplicated parsing and uses isApprovalNotFoundError() for fallback routing/handling.
extensions/telegram/src/exec-approval-resolver.ts Removes duplicated parsing and uses isApprovalNotFoundError() for plugin fallback decisions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9942a423d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugin-sdk/infra-runtime.ts Outdated
@gumadeiras gumadeiras self-assigned this Apr 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Apr 4, 2026
@gumadeiras
gumadeiras force-pushed the codex/approval-error-dedupe branch 2 times, most recently from 0014b56 to 9e21f1b Compare April 4, 2026 16:33
@gumadeiras
gumadeiras force-pushed the codex/approval-error-dedupe branch from d29827b to 108221f Compare April 4, 2026 17:23
@gumadeiras
gumadeiras merged commit e627f53 into main Apr 4, 2026
8 checks passed
@gumadeiras
gumadeiras deleted the codex/approval-error-dedupe branch April 4, 2026 17:24
@gumadeiras

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @gumadeiras!

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Merged via squash.

Prepared head SHA: 108221f
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Merged via squash.

Prepared head SHA: 108221f
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Merged via squash.

Prepared head SHA: 108221f
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: 108221f
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
Merged via squash.

Prepared head SHA: 108221f
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants