Skip to content

[OPIK-5359] [BE] [SDK] fix: improve pairing code error messages and CLI URL logging#5979

Closed
JetoPistola wants to merge 3 commits into
mainfrom
danield/OPIK-5359-improve-pairing-error-messages
Closed

[OPIK-5359] [BE] [SDK] fix: improve pairing code error messages and CLI URL logging#5979
JetoPistola wants to merge 3 commits into
mainfrom
danield/OPIK-5359-improve-pairing-error-messages

Conversation

@JetoPistola
Copy link
Copy Markdown
Contributor

@JetoPistola JetoPistola commented Mar 30, 2026

Details

Improve error messages when opik connect --pair fails, to help users diagnose environment mismatch issues. Currently the error "Invalid or expired pairing code" is unhelpful — it doesn't indicate which backend was targeted or why the code wasn't found.

This PR will:

  • SDK: Include the backend URL in CLI error output when pairing fails
  • BE: Distinguish between code-not-found, expired, and already-consumed failure modes
image

Architecture / Flow Diagram

┌─────────────────────────────────────────────────────────────────────────┐
│                        PAIRING CODE FLOW                                │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│  ┌──────────┐    POST /v1/private/          ┌──────────────┐            │
│  │  Opik UI  │──── local-runners/pair ──────▶│   Backend    │            │
│  │ (Browser) │                               │  (Java API)  │            │
│  └──────────┘                               └──────┬───────┘            │
│                                                     │                    │
│                                              Generate 6-char code        │
│                                              Store in Redis:             │
│                                              key: opik:runners:pair:{CODE}│
│                                              TTL: 300s                   │
│                                                     │                    │
│                                              ┌──────▼───────┐            │
│                                              │    Redis      │            │
│                                              │  (env-specific)│           │
│                                              └──────▲───────┘            │
│                                                     │                    │
│  ┌──────────┐    POST /v1/private/          ┌──────┴───────┐            │
│  │   CLI    │──── local-runners/            │   Backend    │            │
│  │ (opik   │     connections                │  (Java API)  │            │
│  │ connect) │◀──────────────────────────────│              │            │
│  └──────────┘                               └──────────────┘            │
│       │                                                                  │
│       │  URL resolved from:                                              │
│       │  1. Passed values                                                │
│       │  2. Session config                                               │
│       │  3. OPIK_URL_OVERRIDE env var                                    │
│       │  4. ~/.opik.config                                               │
│       │  5. Default: https://www.comet.com/opik/api/ (PROD)              │
│       │                                                                  │
├───────┴──────────────────────────────────────────────────────────────────┤
│                     ⚠️  THE PROBLEM                                      │
│                                                                          │
│  If UI generates code on TEST env Redis, but CLI hits PROD backend       │
│  (different Redis) → code doesn't exist → "Invalid or expired"           │
│                                                                          │
│  ┌─────────┐         ┌──────────────┐     ┌──────────────┐              │
│  │ TEST UI │──code──▶│ TEST Redis   │     │ PROD Redis   │◀── CLI hits  │
│  └─────────┘         │ (has code)   │     │ (no code!)   │    here      │
│                      └──────────────┘     └──────────────┘              │
├──────────────────────────────────────────────────────────────────────────┤
│                     🔧 PROPOSED CHANGES                                  │
│                                                                          │
│  SDK (connect.py):                                                       │
│  ┌──────────────────────────────────────────────────────────────────┐    │
│  │ except ApiError as e:                                            │    │
│  │-    click.echo(f"Error: {e.body}")                               │    │
│  │+    click.echo(f"Error: {e.body} (targeting {config.url})")      │    │
│  └──────────────────────────────────────────────────────────────────┘    │
│                                                                          │
│  Backend (LocalRunnerService.java):                                      │
│  ┌──────────────────────────────────────────────────────────────────┐    │
│  │  claimPairingCode():                                             │    │
│  │  - Add logging: code attempted, Redis key queried                │    │
│  │  - Consider: get() before getAndDelete() to distinguish          │    │
│  │    "never existed" vs "expired" vs "already consumed"            │    │
│  └──────────────────────────────────────────────────────────────────┘    │
└──────────────────────────────────────────────────────────────────────────┘

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-5359

AI-WATERMARK

AI-WATERMARK: yes

  • Tools: Claude Code
  • Model(s): Claude Opus 4.6
  • Scope: PR setup and planning
  • Human verification: code review pending

Testing

No code changes yet — this is a draft PR for implementation planning.

Documentation

N/A — will update if CLI help text changes.

…LI URL logging

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JetoPistola JetoPistola added the test-environment Deploy Opik adhoc environment label Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔄 Test environment deployment process has started

Phase 1: Deploying base version 1.10.57-4756 (from main branch) if environment doesn't exist
Phase 2: Building new images from PR branch danield/OPIK-5359-improve-pairing-error-messages
Phase 3: Will deploy newly built version after build completes

You can monitor the progress here.

@CometActions
Copy link
Copy Markdown
Collaborator

Test environment is now available!

To configure additional Environment variables for your environment, run [Deploy Opik AdHoc Environment workflow] (https://github.com/comet-ml/comet-deployment/actions/workflows/deploy_opik_adhoc_env.yaml)

Access Information

The deployment has completed successfully and the version has been verified.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions CometActions removed the test-environment Deploy Opik adhoc environment label Apr 1, 2026
@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

13 similar comments
@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@CometActions
Copy link
Copy Markdown
Collaborator

🌙 Nightly cleanup: The test environment for this PR (pr-5979) has been cleaned up to free cluster resources. PVCs are preserved — re-deploy to restore the environment.

@andrescrz
Copy link
Copy Markdown
Member

Hi @JetoPistola , thanks for your contribution.

We’re going to close this PR for now since it’s been inactive for a while.

Please feel free to reopen it (or open a new one) whenever you’re ready to resume work—we’d be happy to review it again.

@andrescrz andrescrz closed this Apr 15, 2026
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