Conversation
…workspace selection and update related tests
…ng` for improved flexibility in assertions
…t used; update related test
…le`; adjust logic and tests accordingly. Fixed warning to be more specific.
| workspace = "workspace1" | ||
|
|
||
| OpikConfigurator(api_key, workspace, url)._update_config() | ||
| OpikConfigurator(api_key, workspace, url)._update_config(save_to_file=True) |
Contributor
There was a problem hiding this comment.
This test calls the private helper OpikConfigurator._update_config(save_to_file=True) directly; should we rework it and other direct _update_config calls in this file to exercise the public OpikConfigurator.configure() with the needed flags/mocks?
Finding type: AI Coding Guidelines | Severity: 🟢 Low
Want Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents:
Before applying, verify this suggestion against the current code. In
sdks/python/tests/unit/configurator/test_configure.py around lines 150 to 150, the test
directly calls the private helper OpikConfigurator._update_config(save_to_file=True).
Replace this with a call to the public entrypoint OpikConfigurator.configure(...) so the
test exercises the public API; invoke configure() with the same context (e.g. set any
flags like force or automatic_approvals, and ensure mocks are arranged so configure()
will perform the same save_to_file behavior). Also review and replace other direct
_update_config calls in this file around lines ~182, ~204, ~1254, ~1281, and ~1332 to
use OpikConfigurator.configure(...) instead, keeping assertions and mocks
(mock_opik_config, mock_update_session_config, mock_config_instance.save_to_file, etc.)
unchanged so the tests still assert the same outcomes.
alexkuzmik
approved these changes
Apr 1, 2026
configure(force=True) still prompts interactively for workspaceconfigure(force=True) still prompts interactively for workspace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
Source: Claude session 2, issue #2
Even with force=True, configure() prompts "Do you want to use 'lothiraldan' workspace? (Y/n)" which causes EOFError in non-interactive (piped) execution. Had to discover and add both workspace= and automatic_approvals=True to suppress it.
force=True should imply non-interactive mode and skip all interactive prompts.
Steps to reproduce:
Severity:
Major
Source: Claude session 2, issue #4
An existing ~/.opik.config had a different API key. Without force=True, configure() silently used the old key, then traces failed with: Unauthorized message type 'CreateTraceBatchMessage' processing request: {'code': 401, 'message': 'User not allowed to access workspace!'}.
The 401 error gave no hint that the wrong API key was being used or that the config file was overriding the programmatic key.
Steps to reproduce:
Expected:
Either warn that a config file is overriding the programmatic key, or the programmatic key should take precedence.
Severity:
Major
Summary
This branch improves the
OpikConfiguratorbehaviour around theforceflag, adds a user-facing warning when a provided API key is silently ignored, and tightens the_update_configsignature to prevent accidental silent no-ops.Changes
sdks/python/src/opik/configurator/configure.py1.
_update_config—save_to_fileis now requiredThe
save_to_fileparameter no longer has a default value (True→ no default). Every call site must now explicitly passsave_to_file=Trueorsave_to_file=False, making the intent visible at the call site and preventing accidental file writes.2. Warning when a provided API key is not persisted
When the caller provides an
api_keybutforce=Falseand an API key already exists in the configuration file, aLOGGER.warningis now emitted:Previously no feedback was given in this case, leaving users confused about why their new key was not saved.
3.
forcebypasses workspace approval prompt_set_workspacenow treatsforce=Truethe same asautomatic_approvals=Truewhen deciding whether to prompt the user to confirm the default workspace. This avoids an interactive prompt in automated/forced flows.sdks/python/tests/unit/configurator/test_configure.pyUpdated existing tests
All
_update_config()call sites in tests were updated to pass the now-requiredsave_to_file=Truekeyword argument explicitly, keeping them aligned with the new signature.New test: warning when API key already set in config
TestGetApiKey::test_set_api_key__provided_api_key__another_key_already_set_in_config__not_forced__warning_is_shownVerifies that
LOGGER.warningis called with the correct message when:OpikConfiguratorcurrent_config.api_key is not None)force=FalseAlso asserts that
needs_updateisFalse(the config file is not overwritten).New test:
forceskips workspace approvalTestGetWorkspace::test_get_workspace_accept_default__force_enabled__no_approval_questions_askedVerifies that when
force=Truethe default workspace is accepted automatically andask_user_for_approvalis never called, even whenautomatic_approvals=False.Change checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
Testing
Created related unit tests
Documentation
No changes