Skip to content

Allow alternate Zalo Bot API roots#98768

Merged
RomneyDa merged 2 commits into
mainfrom
feat/zalo-api-root
Jul 3, 2026
Merged

Allow alternate Zalo Bot API roots#98768
RomneyDa merged 2 commits into
mainfrom
feat/zalo-api-root

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

  • allow trusted process/CI configuration to point the Zalo Bot client at an alternate HTTP(S) API root
  • preserve explicit client-option precedence and the production Zalo endpoint by default
  • block ZALO_API_URL from workspace dotenv propagation
  • preserve provider timestamps that already arrive in milliseconds while continuing to normalize epoch seconds

Stack

Tests

  • node scripts/run-vitest.mjs extensions/zalo/src/api.test.ts extensions/zalo/src/monitor.image.polling.test.ts src/infra/dotenv.test.ts
  • pnpm format:check extensions/zalo/src/api.ts extensions/zalo/src/api.test.ts extensions/zalo/src/monitor.ts extensions/zalo/src/monitor.image.polling.test.ts src/infra/dotenv.ts src/infra/dotenv.test.ts
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base 91342b007d --stream-engine-output (clean, no actionable findings)

@openclaw-barnacle openclaw-barnacle Bot added channel: zalo Channel integration: zalo size: S maintainer Maintainer-authored PR labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 2, 2026, 9:17 PM ET / 01:17 UTC.

Summary
The PR adds a ZALO_API_URL API-root override for Zalo Bot API calls, blocks that key from workspace dotenv loading, and preserves millisecond Zalo timestamps.

PR surface: Source +32, Tests +80. Total +112 across 6 files.

Reproducibility: not applicable. this is a feature/config-surface PR rather than a reported bug. Source inspection confirms current main has a fixed Zalo API root and the PR adds the alternate-root path with focused tests.

Review metrics: 2 noteworthy metrics.

  • Endpoint env surface: 1 added (ZALO_API_URL). A new trusted process/global environment variable can change runtime Zalo API routing and needs explicit compatibility review.
  • Workspace dotenv guard: 1 blocked key added. The blocklist entry is the mitigation that keeps untrusted workspace .env files from steering bot-token traffic.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • Document ZALO_API_URL in the Zalo channel docs and workspace-dotenv security docs.
  • [P2] Have maintainers explicitly accept the trusted global-env endpoint override before merge.

Risk before merge

  • [P1] A pre-existing trusted process/global ZALO_API_URL value would redirect Zalo Bot API requests and bot tokens after upgrade.
  • [P1] The public Zalo and workspace-dotenv security docs do not yet describe the override, trusted sources, default production endpoint, or why workspace .env is ignored.

Maintainer options:

  1. Document and accept the env contract (recommended)
    Add the Zalo and workspace-dotenv docs for ZALO_API_URL, then have a maintainer accept the global-env upgrade behavior before merge.
  2. Keep it as an internal escape hatch
    Maintainers can intentionally merge without public docs, but they would own the upgrade ambiguity for pre-existing ZALO_API_URL values.
  3. Pause if another env knob is unwanted
    If maintainers do not want another endpoint env surface, pause or close this PR and keep the fixed production Zalo endpoint.

Next step before merge

  • [P2] The remaining action is maintainer acceptance of a compatibility-sensitive env routing surface plus docs, not an autonomous repair lane.

Security
Cleared: No concrete supply-chain regression found; the endpoint override is limited to explicit options or trusted process/global env, and workspace dotenv redirection is blocked for the new key.

Review findings

  • [P3] Document the Zalo API root override — extensions/zalo/src/api.ts:11
Review details

Best possible solution:

Land only after maintainers accept the trusted ZALO_API_URL contract and the docs describe the production default, trusted sources, and workspace dotenv block.

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

Not applicable: this is a feature/config-surface PR rather than a reported bug. Source inspection confirms current main has a fixed Zalo API root and the PR adds the alternate-root path with focused tests.

Is this the best way to solve the issue?

Mostly yes: resolving the root inside callZaloApi is the narrow owner-boundary fix because Zalo API helpers funnel through that function. The merge-ready version still needs maintainer acceptance and docs for the trusted env contract.

Full review comments:

  • [P3] Document the Zalo API root override — extensions/zalo/src/api.ts:11
    This introduces ZALO_API_URL as a runtime endpoint override, but docs/channels/zalo.md still documents only ZALO_BOT_TOKEN and docs/gateway/security/index.md lists endpoint dotenv blocking without Zalo. Please document trusted process/global sources, the production default, and workspace .env blocking so operators know the contract.
    Confidence: 0.86

Overall correctness: patch is correct
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded Zalo channel feature with limited blast radius but real operator-facing compatibility impact.
  • merge-risk: 🚨 compatibility: A pre-existing ZALO_API_URL process/global environment value would redirect Zalo API requests and bot tokens after upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer-labeled MEMBER PR; the PR body's targeted test list is supplemental validation.
Evidence reviewed

PR surface:

Source +32, Tests +80. Total +112 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 36 4 +32
Tests 3 80 0 +80
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 116 4 +112

What I checked:

  • Repository policy applied: Root AGENTS.md was read fully and treats provider routing, config/default additions, setup/startup checks, and fallback behavior as compatibility-sensitive; extensions/AGENTS.md keeps bundled plugin behavior inside the plugin boundary. (AGENTS.md:31, 381b44a9fc26)
  • Current main lacks alternate Zalo API roots: Current main defines a fixed ZALO_API_BASE and constructs every callZaloApi request from that production root, so the requested behavior is not already implemented on main. (extensions/zalo/src/api.ts:10, 381b44a9fc26)
  • PR head centralizes the endpoint override: At the PR head, resolveZaloApiUrl reads an explicit option first, otherwise process.env.ZALO_API_URL, validates HTTP(S), strips trailing slashes, and feeds the shared callZaloApi URL construction. (extensions/zalo/src/api.ts:108, 84d84f7f9a37)
  • Shared Zalo caller path checked: Polling, send, probe, webhook setup, webhook cleanup, typing, and pairing replies all route through helpers in api.ts, so the endpoint change is not a one-sided path patch. (extensions/zalo/src/monitor.ts:259, 381b44a9fc26)
  • Workspace dotenv mitigation exists on PR head: The PR adds ZALO_API_URL to the workspace dotenv blocklist and extends tests to prove workspace .env cannot set it while trusted global .env still can. (src/infra/dotenv.ts:171, 84d84f7f9a37)
  • Docs gap remains: The Zalo docs still document ZALO_BOT_TOKEN but not ZALO_API_URL, and the security guide's workspace dotenv endpoint list mentions Matrix, Mattermost, IRC, and Synology Chat but not Zalo. Public docs: docs/channels/zalo.md. (docs/channels/zalo.md:95, 381b44a9fc26)

Likely related people:

  • steipete: Commit 5abe3c2 introduced the Zalo plugin/API client, and shortlog/history show the largest share of Zalo API, monitor, and docs changes in this area. (role: introduced behavior and heavy Zalo area contributor; confidence: high; commits: 5abe3c21456e, 58baf22230e0, 453664f09d09; files: extensions/zalo/src/api.ts, extensions/zalo/src/monitor.ts, docs/channels/zalo.md)
  • RomneyDa: Beyond authoring this PR, RomneyDa authored the merged Slack alternate API-root PR and the merged Zalo identity-contract base that this PR was restacked on. (role: adjacent endpoint-surface owner; confidence: high; commits: 39e1be080ca0, 381b44a9fc26, 84d84f7f9a37; files: extensions/slack/src/client-options.ts, src/infra/dotenv.ts, extensions/zalo/src/api.ts)
  • Devin Robison: Commit 6a79324 introduced the untrusted CWD .env filtering boundary that this PR extends for Zalo endpoint routing. (role: dotenv trust-boundary contributor; confidence: medium; commits: 6a793248024d; files: src/infra/dotenv.ts, src/infra/dotenv.test.ts)
  • Vincent Koc: Recent history shows Zalo runtime/API and dotenv-adjacent maintenance by Vincent Koc, including Zalo runtime seam work and shared dotenv edits. (role: recent Zalo and dotenv area contributor; confidence: medium; commits: 76c22217174c, 58409cd5c570, 11590eb6ce38; files: extensions/zalo/src/api.ts, extensions/zalo/src/monitor.ts, src/infra/dotenv.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 1, 2026
@RomneyDa
RomneyDa force-pushed the feat/zalo-api-root branch from 05cc890 to 45ba233 Compare July 3, 2026 00:47
@RomneyDa
RomneyDa changed the base branch from main to fix/zalo-bot-info-contract July 3, 2026 00:47
Base automatically changed from fix/zalo-bot-info-contract to main July 3, 2026 01:06
@RomneyDa
RomneyDa force-pushed the feat/zalo-api-root branch from 45ba233 to 84d84f7 Compare July 3, 2026 01:08
@RomneyDa
RomneyDa merged commit 84c9f05 into main Jul 3, 2026
150 of 151 checks passed
@RomneyDa
RomneyDa deleted the feat/zalo-api-root branch July 3, 2026 01:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 3, 2026
* Allow alternate Zalo Bot API roots

* Normalize Zalo provider timestamps
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
* Allow alternate Zalo Bot API roots

* Normalize Zalo provider timestamps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: zalo Channel integration: zalo maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant