Fix callback URL to use configurable public base #6

Merged
thuanle merged 2 commits from fix/callback-base-url into main 2026-04-27 21:05:23 +07:00
Collaborator

Summary

  • Add CALLBACK_BASE_URL config and default it to http://localhost when unset.
  • Build OpenClaw dispatch callback_url from CALLBACK_BASE_URL instead of LISTEN_ADDR.
  • Add tests for config fallback/env override and callback URL generation behavior.
  • Update .env.example and README config documentation.

Test Plan

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...

Notes

  • LISTEN_ADDR remains server bind address only.
  • callback_url is now deployment-friendly while still working locally by default.
## Summary - Add `CALLBACK_BASE_URL` config and default it to `http://localhost` when unset. - Build OpenClaw dispatch `callback_url` from `CALLBACK_BASE_URL` instead of `LISTEN_ADDR`. - Add tests for config fallback/env override and callback URL generation behavior. - Update `.env.example` and README config documentation. ## Test Plan - [x] `go test ./internal/config -run CallbackBaseURL -v` - [x] `go test ./internal/ai_client -run UsesCallbackBaseURL -v` - [x] `go test ./...` ## Notes - `LISTEN_ADDR` remains server bind address only. - `callback_url` is now deployment-friendly while still working locally by default.
claudecode added 1 commit 2026-04-27 19:03:21 +07:00
Separate callback URL generation from LISTEN_ADDR by introducing CALLBACK_BASE_URL with a localhost default for local development.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
thuanle requested review from codex 2026-04-27 19:05:20 +07:00
Collaborator

FAIL

  1. [High] CALLBACK_BASE_URL default vẫn tạo callback URL sai cho setup mặc định đang được document. internal/config/config.go:76-80 default listener là :8080 nhưng default callback base lại là http://localhost, và internal/ai_client/client.go:133-138 sẽ build thành http://localhost/callback thay vì http://localhost:8080/callback. Mismatch này cũng xuất hiện trong .env.example:24-25, README.md:76-77, và test expectation ở internal/config/config_test.go:24-35. Kết quả là local/default setup vẫn gửi callback về port 80 trong khi bridge thực tế listen ở 8080.

Validation:

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...
FAIL 1. [High] `CALLBACK_BASE_URL` default vẫn tạo callback URL sai cho setup mặc định đang được document. `internal/config/config.go:76-80` default listener là `:8080` nhưng default callback base lại là `http://localhost`, và `internal/ai_client/client.go:133-138` sẽ build thành `http://localhost/callback` thay vì `http://localhost:8080/callback`. Mismatch này cũng xuất hiện trong `.env.example:24-25`, `README.md:76-77`, và test expectation ở `internal/config/config_test.go:24-35`. Kết quả là local/default setup vẫn gửi callback về port 80 trong khi bridge thực tế listen ở 8080. Validation: - `go test ./internal/config -run CallbackBaseURL -v` - `go test ./internal/ai_client -run UsesCallbackBaseURL -v` - `go test ./...`
codex requested changes 2026-04-27 19:11:48 +07:00
codex left a comment
Collaborator

FAIL

  1. [High] CALLBACK_BASE_URL default vẫn tạo callback URL sai cho setup mặc định đang được document. internal/config/config.go:76-80 default listener là :8080 nhưng default callback base lại là http://localhost, và internal/ai_client/client.go:133-138 sẽ build thành http://localhost/callback thay vì http://localhost:8080/callback. Mismatch này cũng xuất hiện trong .env.example:24-25, README.md:76-77, và test expectation ở internal/config/config_test.go:24-35. Kết quả là local/default setup vẫn gửi callback về port 80 trong khi bridge thực tế listen ở 8080.

Validation:

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...
FAIL 1. [High] `CALLBACK_BASE_URL` default vẫn tạo callback URL sai cho setup mặc định đang được document. `internal/config/config.go:76-80` default listener là `:8080` nhưng default callback base lại là `http://localhost`, và `internal/ai_client/client.go:133-138` sẽ build thành `http://localhost/callback` thay vì `http://localhost:8080/callback`. Mismatch này cũng xuất hiện trong `.env.example:24-25`, `README.md:76-77`, và test expectation ở `internal/config/config_test.go:24-35`. Kết quả là local/default setup vẫn gửi callback về port 80 trong khi bridge thực tế listen ở 8080. Validation: - `go test ./internal/config -run CallbackBaseURL -v` - `go test ./internal/ai_client -run UsesCallbackBaseURL -v` - `go test ./...`
codex requested changes 2026-04-27 19:12:00 +07:00
codex left a comment
Collaborator

FAIL

  1. [High] CALLBACK_BASE_URL default vẫn tạo callback URL sai cho setup mặc định đang được document. internal/config/config.go:76-80 default listener là :8080 nhưng default callback base lại là http://localhost, và internal/ai_client/client.go:133-138 sẽ build thành http://localhost/callback thay vì http://localhost:8080/callback. Mismatch này cũng xuất hiện trong .env.example:24-25, README.md:76-77, và test expectation ở internal/config/config_test.go:24-35. Kết quả là local/default setup vẫn gửi callback về port 80 trong khi bridge thực tế listen ở 8080.

Validation:

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...
FAIL 1. [High] `CALLBACK_BASE_URL` default vẫn tạo callback URL sai cho setup mặc định đang được document. `internal/config/config.go:76-80` default listener là `:8080` nhưng default callback base lại là `http://localhost`, và `internal/ai_client/client.go:133-138` sẽ build thành `http://localhost/callback` thay vì `http://localhost:8080/callback`. Mismatch này cũng xuất hiện trong `.env.example:24-25`, `README.md:76-77`, và test expectation ở `internal/config/config_test.go:24-35`. Kết quả là local/default setup vẫn gửi callback về port 80 trong khi bridge thực tế listen ở 8080. Validation: - `go test ./internal/config -run CallbackBaseURL -v` - `go test ./internal/ai_client -run UsesCallbackBaseURL -v` - `go test ./...`
thuanle added 1 commit 2026-04-27 20:56:53 +07:00
Derive CALLBACK_BASE_URL fallback from LISTEN_ADDR so default local setup resolves to localhost:8080 and stays aligned with server bind port.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Author
Collaborator

Update for review feedback

Đã xử lý item [High] về mismatch default callback port.

Changes applied

  • CALLBACK_BASE_URL fallback không còn hard-code http://localhost.
  • Khi CALLBACK_BASE_URL unset, fallback được suy ra từ LISTEN_ADDR:
    • :8080 -> http://localhost:8080
    • :9090 -> http://localhost:9090
    • 0.0.0.0:<port> / ::<port> -> localhost:<port>
  • Đồng bộ docs/examples:
    • .env.example default CALLBACK_BASE_URL=http://localhost:8080
    • README mô tả default theo LISTEN_ADDR.

Files

  • internal/config/config.go
  • internal/config/config_test.go
  • internal/ai_client/client.go
  • .env.example
  • README.md

Verification

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...

Commit pushed: 2168042.

## Update for review feedback Đã xử lý item `[High]` về mismatch default callback port. ### Changes applied - `CALLBACK_BASE_URL` fallback không còn hard-code `http://localhost`. - Khi `CALLBACK_BASE_URL` unset, fallback được suy ra từ `LISTEN_ADDR`: - `:8080` -> `http://localhost:8080` - `:9090` -> `http://localhost:9090` - `0.0.0.0:<port>` / `::<port>` -> `localhost:<port>` - Đồng bộ docs/examples: - `.env.example` default `CALLBACK_BASE_URL=http://localhost:8080` - README mô tả default theo `LISTEN_ADDR`. ### Files - `internal/config/config.go` - `internal/config/config_test.go` - `internal/ai_client/client.go` - `.env.example` - `README.md` ### Verification - `go test ./internal/config -run CallbackBaseURL -v` ✅ - `go test ./internal/ai_client -run UsesCallbackBaseURL -v` ✅ - `go test ./...` ✅ Commit pushed: `2168042`.
codex approved these changes 2026-04-27 21:04:32 +07:00
codex left a comment
Collaborator

PASS

No blocking issues found in the latest update.

Validation:

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...

Non-blocking note:

  • defaultCallbackBaseURL still has an IPv6 edge case when LISTEN_ADDR is an IPv6 literal such as [::1]:8080; that path is not covered by tests today.
PASS No blocking issues found in the latest update. Validation: - `go test ./internal/config -run CallbackBaseURL -v` - `go test ./internal/ai_client -run UsesCallbackBaseURL -v` - `go test ./...` Non-blocking note: - `defaultCallbackBaseURL` still has an IPv6 edge case when `LISTEN_ADDR` is an IPv6 literal such as `[::1]:8080`; that path is not covered by tests today.
codex approved these changes 2026-04-27 21:04:42 +07:00
codex left a comment
Collaborator

PASS

No blocking issues found in the latest update.

Validation:

  • go test ./internal/config -run CallbackBaseURL -v
  • go test ./internal/ai_client -run UsesCallbackBaseURL -v
  • go test ./...

Non-blocking note:

  • defaultCallbackBaseURL still has an IPv6 edge case when LISTEN_ADDR is an IPv6 literal such as [::1]:8080; that path is not covered by tests today.
PASS No blocking issues found in the latest update. Validation: - `go test ./internal/config -run CallbackBaseURL -v` - `go test ./internal/ai_client -run UsesCallbackBaseURL -v` - `go test ./...` Non-blocking note: - `defaultCallbackBaseURL` still has an IPv6 edge case when `LISTEN_ADDR` is an IPv6 literal such as `[::1]:8080`; that path is not covered by tests today.
thuanle merged commit 0aa95915a2 into main 2026-04-27 21:05:23 +07:00
thuanle deleted branch fix/callback-base-url 2026-04-27 21:05:27 +07:00
Sign in to join this conversation.
No Reviewers
No labels
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thuanle/claw-email#6