Skip to content

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

Merged
robert-chiniquy merged 4 commits into
mainfrom
rch/testability/fix-base-url
May 1, 2026
Merged

Add --base-url flag for connector testability#71
robert-chiniquy merged 4 commits into
mainfrom
rch/testability/fix-base-url

Conversation

@robert-chiniquy

Copy link
Copy Markdown
Contributor

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

pkg/config/conf.gen.go,pkg/config/config.go,pkg/connector/connector.go

Testing

The connector can now be tested against mock servers:

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

Related

Part of the Connector Testability initiative.

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

coderabbitai Bot commented Feb 8, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@robert-chiniquy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 1 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing Touches
🧪 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.

@russellhaering russellhaering left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — base-url correctly takes precedence over gov-env flag.

This change adds a --base-url CLI flag to allow overriding the default API
endpoint for testing purposes. When provided, the connector will use this
URL instead of the hardcoded production API URL.

This is part of the Connector Testability initiative to enable mock server
testing without modifying connector code.

Files changed: pkg/config/conf.gen.go,pkg/config/config.go,pkg/connector/connector.go
base-url is a dev/testing concern, not user-facing configuration.
Mark it WithHidden(true) so it doesn't appear in the hosted UI.

Good feedback from Geoff:
ConductorOne/baton-trayai#63 (comment)
@c1-squire-dev
c1-squire-dev Bot force-pushed the rch/testability/fix-base-url branch from badb007 to f857788 Compare May 1, 2026 18:28
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @c1-squire-dev[bot]'s task in 1m 13s —— View job


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

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

Overall: Clean, well-scoped change. The primary Slack client correctly gets the base URL override, and the field configuration (hidden, CLI-only) is appropriate. Two reviewers have already approved. I have one substantive concern and one minor note.


Issue: Business+ client does not receive the base URL override

The --base-url flag overrides the API URL for the primary slack.Client (pkg/connector/connector.go:118-119), but the businessPlusClient created at line 127-133 still calls client.NewClient(httpClient, businessPlusKey, apiKey, govEnv) — which only switches between https://slack.com and https://slack-gov.com based on govEnv (see pkg/connector/client/slack.go:46-53).

This means when testing with --base-url http://localhost:8080, any operations that go through the Business+ client (SCIM operations, user group members, teams list, etc.) will still hit production Slack URLs, not the mock server. This could cause confusing test failures or, worse, unintended calls to production during testing.

If this is intentional (e.g., the testability initiative only targets the primary client for now), it would be worth documenting. Otherwise, the client.NewClient function should also accept and respect the base URL override.

Fix this →

Minor: URL format expectation

The govSlackApiUrl constant is "https://api.slack-gov.com/api/" (with /api/ path and trailing slash). The slack.OptionAPIURL in the slack-go library expects this format. Users providing --base-url will need to know to include the trailing /api/ path segment for the primary client to work correctly. Since this is a testing/power-user flag, this is acceptable — but worth noting in documentation or the field description if it trips people up.


Note: I was unable to run go build or go vet due to missing tool permissions, so this review is based on static code reading only.

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @c1-squire-dev[bot]'s task in 1m 10s —— View job


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

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

Overall: Clean, well-scoped change. The field configuration (WithHidden, WithExportTarget(CLIOnly)) is appropriate, and the precedence logic (custom URL > gov env > default) is correct. The goconst cleanup in the second commit is fine. One substantive issue remains from the prior review.


Issue: Business+ client does not receive the base URL override

The --base-url flag overrides the API URL for the primary slack.Client (pkg/connector/connector.go:118-119), but the businessPlusClient created at lines 128-133 still calls client.NewClient(httpClient, businessPlusKey, apiKey, govEnv) without receiving baseURL.

Looking at pkg/connector/client/path.go, the Business+ client uses two separate base URLs:

  • baseUrl = https://slack.com (for standard API calls like users.list, usergroups.list)
  • baseScimUrl = https://api.slack.com (for SCIM operations like disable/enable user, IDP group management)

When testing with --base-url http://localhost:8080, any operations going through the Business+ client — SCIM user enable/disable, IDP group listing, user group members, team listing, and all provisioning operations — will still hit production Slack URLs, not the mock server.

This means the testability story is incomplete: the primary read path (via slack.Client) can be redirected, but provisioning and Business+ operations cannot.

Recommendation: Pass baseURL to client.NewClient and use it to override both baseUrl and baseScimUrl when non-empty.

Fix this →

Minor: URL format expectation

The slack-go library's OptionAPIURL expects a URL with the /api/ path suffix (the govSlackApiUrl constant is https://api.slack-gov.com/api/). Users providing --base-url need to include this trailing path. Since this is a testing/power-user flag, it's acceptable — but if it trips people up, a note in the field description or URL normalization would help.

Nit: Field naming inconsistency

The generated struct field is BaseUrl (pkg/config/conf.gen.go:10) while the field variable is BaseURLField (pkg/config/config.go:17). This follows from the mapstructure tag base-urlBaseUrl, so it's a generated-code artifact, not something to fix — just noting it for awareness.


Note: I was unable to run go build or go vet due to missing tool permissions, so this review is based on static code reading only.

@robert-chiniquy
robert-chiniquy merged commit 38405c7 into main May 1, 2026
10 checks passed
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