Skip to content

Add --base-url flag for connector testability#74

Open
robert-chiniquy wants to merge 1 commit intomainfrom
rch/testability/fix-base-url
Open

Add --base-url flag for connector testability#74
robert-chiniquy wants to merge 1 commit intomainfrom
rch/testability/fix-base-url

Conversation

@robert-chiniquy
Copy link

@robert-chiniquy robert-chiniquy commented Feb 8, 2026

Summary

Adds the --base-url CLI flag to enable overriding the default API endpoint for testing purposes.

Changes

  • Added BaseURLField to configuration
  • Updated client/connector to accept and use the base URL override
  • When --base-url is provided, it takes precedence over the default API URL

Files Modified

cmd/baton-temporalcloud/main.go,pkg/connector/connector.go

Testing

The connector can now be tested against mock servers:

baton-temporalcloud --base-url http://localhost:8080 [other-flags]

Related

Part of the Connector Testability initiative.

Summary by CodeRabbit

  • New Features
    • Added configuration support for custom Temporal Cloud API URL, allowing users to specify an alternate API endpoint.

@robert-chiniquy robert-chiniquy requested a review from a team February 8, 2026 07:59
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

This pull request adds support for overriding the Temporal Cloud API base URL through configuration, enabling users to specify a custom endpoint for testing purposes. The implementation spans configuration structure definitions, field registration, and client initialization logic.

Changes

Cohort / File(s) Summary
Configuration Structure
pkg/config/conf.gen.go, pkg/config/config.go
Added new BaseUrl field to the TemporalCloud struct with mapstructure tag, and registered BaseURLField as a hidden CLI-only configuration parameter with description for overriding the API URL.
Client Initialization
pkg/connector/connector.go
Integrated the configured base URL into Temporal Cloud client options by appending client.WithAPIAddress() when BaseUrl is provided during client construction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A URL to override, a custom API guide,
Testing clouds now bend to our tide,
Configuration blooms with purpose clear,
The connector listens when custom endpoints appear.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a --base-url flag to enable testing the connector against different API endpoints.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rch/testability/fix-base-url

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@russellhaering russellhaering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - base-url flag implementation looks correct. Clean integration via the existing functional options pattern (client.WithAPIAddress). Default behavior preserved when baseURL is empty.

Reworked for RunConnector architecture. Adds base-url config field
with WithHidden and ExportTargetCLIOnly, wires through to
client.WithAPIAddress().

Ref: ConductorOne/baton-prismhr#13 (comment)
@robert-chiniquy robert-chiniquy force-pushed the rch/testability/fix-base-url branch from 3c7b215 to 37e645b Compare March 8, 2026 01:00
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

Claude finished @robert-chiniquy's task in 1m 14s —— View job


PR Review: Add --base-url flag for connector testability

Blocking Issues: 0 | Suggestions: 0

  • Gather context and read changed files
  • Review code changes
  • Post review feedback

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

Summary

Clean, minimal change that adds a --base-url CLI flag for testing against mock servers. The implementation correctly:

  • Uses field.StringField with WithHidden(true) and WithExportTarget(field.ExportTargetCLIOnly) — appropriate for a testing-only flag that shouldn't appear in UI configuration (config.go:32-37)
  • Conditionally applies client.WithAPIAddress only when a non-empty base URL is provided, preserving default behavior (connector.go:87-89)
  • Integrates via the existing functional options pattern on the client
  • conf.gen.go changes appear to be from code generation (as expected per the DO NOT EDIT header)

No documentation staleness concern — docs/connector.mdx doesn't need updating for a hidden, CLI-only testing flag.

Both existing approvals (russellhaering, gontzess) align with this assessment. LGTM.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/connector/connector.go (1)

85-115: ⚠️ Potential issue | 🔴 Critical

Add a Close() method to properly close the underlying gRPC connection.

The constructor creates a *grpc.ClientConn via NewConnectionWithAPIKey(), passes it to the gRPC stub, but never stores or closes it. The connection reference is lost after New() returns—it lives on only within the gRPC stub's internal state. Without an explicit Close() method on Connector, the connection is never closed, creating a resource leak. Per coding guidelines (**/pkg/connector/connector.go): Implement Close() method for connectors that create clients and properly close them.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/connector/connector.go` around lines 85 - 115, The Connector currently
creates a gRPC connection via client.New (which uses NewConnectionWithAPIKey)
but never retains or closes the underlying *grpc.ClientConn; add a field to the
Connector struct (e.g., conn *grpc.ClientConn) and update New to capture and
store the returned connection when building the cloudServiceClient (or obtain it
from client.New if it returns both), then implement a Close() method on
Connector that closes the stored conn (and also invokes any Close/Shutdown on
cloudServiceClient if available) so the gRPC connection is properly released;
reference the New function, the Connector type, and the cloudServiceClient field
when making these changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/connector/connector.go`:
- Around line 85-115: The Connector currently creates a gRPC connection via
client.New (which uses NewConnectionWithAPIKey) but never retains or closes the
underlying *grpc.ClientConn; add a field to the Connector struct (e.g., conn
*grpc.ClientConn) and update New to capture and store the returned connection
when building the cloudServiceClient (or obtain it from client.New if it returns
both), then implement a Close() method on Connector that closes the stored conn
(and also invokes any Close/Shutdown on cloudServiceClient if available) so the
gRPC connection is properly released; reference the New function, the Connector
type, and the cloudServiceClient field when making these changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61f39ca1-d97a-4166-9300-92bace4dced3

📥 Commits

Reviewing files that changed from the base of the PR and between f1cada8 and 37e645b.

📒 Files selected for processing (3)
  • pkg/config/conf.gen.go
  • pkg/config/config.go
  • pkg/connector/connector.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants