Skip to content

E2E sandbox AI credentials do not reach an RStudio Server session #18348

Closed

Description

@ronblum

This concerns the Playwright E2E suite (e2e/rstudio) and how AI provider
credentials (Posit AI and GitHub Copilot) are provisioned for tests.

Describe the problem

The auth.setup project provisions AI credentials into a per-run sandbox home
($PW_SANDBOX/user-home), and the credential gate reads that sandbox. This
works in Desktop mode, where the IDE reads the sandbox home. In Server mode it
does not: rserver builds each rsession's environment from scratch and takes
the session's HOME from the system password database (getpwnam -> pw_dir),
i.e. the logged-in OS user's real home directory, not the sandbox. So the
credentials written to the sandbox never reach a server rsession, and the AI
features behave as signed-out even though setup reported success.

This affects both providers and pre-dates the Copilot work (it shipped with the
Posit AI credential provisioning in #17680). PR #18342 only surfaces it: the
setup now prints a warning in Server mode that the sandbox credentials will not
reach the session.

Steps to reproduce the problem

On a machine where the logged-in user's real home directory is not signed in to
the provider:

  1. Run a Copilot feature test in server-dev mode:
    npm run test:server-dev -- tests/panes/editor/code_suggestions.test.ts -g "GitHub Copilot"
    
    • The auth.setup project signs in and writes the store to the sandbox, and
      the setup test passes.
  2. The credential gate reads the sandbox, finds it authenticated, and does not
    skip, so the feature test runs.
  3. The feature fails: Copilot ghost text times out, and Posit Assistant chat
    loads but the response comes back empty (or a sign-in overlay blocks it),
    because the rsession read the real home, which has no credentials.

If the logged-in user's real home directory is itself already signed in to the
provider, the tests pass, but only because the rsession reads that pre-existing
local sign-in, not the credentials the setup provisioned into the sandbox. A
green result in that case does not mean the provisioning reached the session.
Confirmed live on an external RStudio Server (Fedora VM) and via
test:server-dev on macOS.

Describe the behavior you expected

Sandbox-provisioned AI credentials should reach the server rsession so the
feature tests exercise real credentials.

What addressing it would involve

Getting sandbox-provisioned credentials to a server rsession, e.g. writing them
into the location the rsession's real HOME resolves to, running the rsession
under a user whose home is the sandbox, or forwarding the credential dirs the
way RSTUDIO_CONFIG_HOME/XDG vars are already forwarded. Likely its own effort,
and it must cover both providers.

See issue #18306. Related: PRs #17680 and #18342.

Activity

  1. self-assigned this
    on Jul 24, 2026
  2. added
    new
    on Jul 24, 2026
  3. ronblum commented on Jul 24, 2026

    @ronblum
    ContributorAuthor

    Traced the exact mechanism behind this while verifying PR #18342.

    fixtures/server.fixture.ts sets HOME, RSTUDIO_CONFIG_HOME, and RSTUDIO_DATA_HOME on the rserver process it spawns, pointing into the sandbox. But rserver never hands that environment to the rsession it forks for the authenticated user. In core/system/PosixSystem.cpp, runProcess() (lines 2696-2703) builds that child's environment from scratch: it copies only PATH, MANPATH, and LANG from the parent, then explicitly sets HOME from user.getHomePath() (the passwd entry) -- none of the sandbox overrides survive.

    Confirmed the effect directly: running code_suggestions.test.ts against test:server-dev, GitHub Copilot failed with the real UI showing "Copilot: Not signed in.", even though the sandbox's own auth.setup step had just completed a real, successful Copilot device-flow sign-in. The credential gate (requireAiCredentials) only checks the sandbox store, so it reported "authenticated" and let the test run instead of skipping -- the mismatch only surfaces downstream, as a feature failure rather than a clean skip.

  4. removed
    new
    on Aug 6, 2026
  5. ronblum commented on Aug 7, 2026

    @ronblum
    ContributorAuthor

    Completed via #18458.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions