Skip to content

docs: fix non-compiling Rust external-transport example - #2142

Merged
SteveSandersonMS merged 1 commit into
mainfrom
sdk-bugfix-122
Jul 30, 2026
Merged

docs: fix non-compiling Rust external-transport example#2142
SteveSandersonMS merged 1 commit into
mainfrom
sdk-bugfix-122

Conversation

@examon

@examon examon commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The Rust example under "Connecting to an external CLI server" in docs/getting-started.md constructed Transport::External { host, port } and omitted the variant's third required field, so the documented example did not compile. This adds connection_token: None,.

Fixes #2141

Why None

  • The server the section tells you to start has no token: copilot --headless --port 4321, which on startup reports No COPILOT_CONNECTION_TOKEN was set, so connections will be accepted from any client.
  • None of the sibling language tabs in the same example pass a token.
  • The only other Rust example that constructs this variant, in docs/setup/multi-tenancy.md, already passes connection_token: None.

Before and after

Against the published crate, installed the way the guide instructs (cargo add github-copilot-sdk --features derive, which resolves to 1.0.8), with the example pasted into an async main as the guide's own complete examples do:

Before:

$ cargo build
error[E0063]: missing field `connection_token` in initializer of `github_copilot_sdk::Transport`
 --> src/main.rs:9:25
  |
9 |     options.transport = Transport::External {
  |                         ^^^^^^^^^^^^^^^^^^^ missing `connection_token`

error: could not compile `copilot-demo` (bin "copilot-demo") due to 1 previous error

After:

$ cargo build
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.62s

The fixed example was also run against a real copilot --headless --port 4321 server: it connects and creates a session, and fails with ConnectionRefused once the server is stopped, so the connection is genuinely going to the external server.

Checks

  • Every Rust fence in docs/getting-started.md was compiled before and after. This change removes the file's only compile error and introduces none.
  • just validate-docs gives the same per-language results before and after; the only difference is a one-line shift in generated block metadata.
  • No Rust source changed, so the Rust build, formatting and lint results are identical to base.

No regression test

There is no test to add: scripts/docs-validation/extract.ts has no rust entry in LANGUAGE_MAP, so Rust fences under docs/ are never extracted and no validator covers them. That is also why this drifted unnoticed. Adding Rust coverage needs a validator and a workflow job, so I have left it out of this change.

Out of scope

Noted while here, kept separate: the TypeScript tab in this same section is separately stale, as it passes cliUrl, which is no longer a CopilotClientOptions field.

The Rust tab of "Connecting the SDK to the external server"
constructed `Transport::External { host, port }` and omitted the
variant's third field, so the example failed to compile:

    error[E0063]: missing field `connection_token` in initializer of `github_copilot_sdk::Transport`

`connection_token` was added to the variant after the example was
written. `None` is the value that matches this section: the server
it tells you to start (`copilot --headless --port 4321`) has no
token, and the other Rust example that constructs this variant, in
docs/setup/multi-tenancy.md, already passes `None`.
@examon
examon requested a review from a team as a code owner July 29, 2026 23:17
Copilot AI review requested due to automatic review settings July 29, 2026 23:17

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

Fixes the Rust external CLI transport example so it compiles with the current SDK API.

Changes:

  • Adds the required connection_token field with None.
Show a summary per file
File Description
docs/getting-started.md Corrects the Rust external transport example.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Medium

@SteveSandersonMS SteveSandersonMS 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.

Reviewed for scope, correctness, cross-language consistency, and manual Rust API validation. The one-line documentation fix is necessary, correct, and minimal.

@SteveSandersonMS
SteveSandersonMS added this pull request to the merge queue Jul 30, 2026
Merged via the queue into main with commit 07d7db5 Jul 30, 2026
30 checks passed
@SteveSandersonMS
SteveSandersonMS deleted the sdk-bugfix-122 branch July 30, 2026 12:35
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.

Rust example in "Connecting to an external CLI server" does not compile (missing connection_token)

3 participants