Skip auth-dependent tests when DEEPL_AUTH_KEY is absent and wire key into CI pytest job#4
Draft
Copilot wants to merge 3 commits into
Draft
Skip auth-dependent tests when DEEPL_AUTH_KEY is absent and wire key into CI pytest job#4Copilot wants to merge 3 commits into
DEEPL_AUTH_KEY is absent and wire key into CI pytest job#4Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/AKB0700/deepl-python/sessions/134f39d6-1635-4a7c-a558-c4ed66e6b556 Co-authored-by: AKB0700 <157992575+AKB0700@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AKB0700/deepl-python/sessions/134f39d6-1635-4a7c-a558-c4ed66e6b556 Co-authored-by: AKB0700 <157992575+AKB0700@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CI job failure due to empty auth key
Skip auth-dependent tests when May 13, 2026
DEEPL_AUTH_KEY is absent and wire key into CI pytest job
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.
CI was running pytest without a configured
DEEPL_AUTH_KEY, causing fixture-backed test setup to instantiatedeepl.Translator/DeepLClientwith an empty key and fail withValueError: auth_key must not be empty. This change keeps runtime auth validation intact and makes test/CI behavior credential-aware.Test fixture gating for real-server auth
tests/conftest.pyso bothtranslatoranddeepl_clientfixtures skip cleanly when:DEEPL_AUTH_KEYis not configured.Auth-independent user-agent tests
tests/test_general.pyuser-agent tests to use a fallback test key (TEST_AUTH_KEY) instead of directos.environ["DEEPL_AUTH_KEY"]access.Additional direct auth-path test guards
tests/test_cli.pyrunnerfixture to skip when real-server auth is missing.tests/test_translate_text.py::test_skip_language_checkto skip under the same condition.Workflow config for integration credentials
.github/workflows/python-package.ymlpytest step to pass:DEEPL_AUTH_KEY: ${{ secrets.DEEPL_AUTH_KEY }}Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.deepl.com/home/REDACTED/.cache/pypoetry/virtualenvs/deepl-mg71yGZ3-py3.12/bin/pytest /home/REDACTED/.cache/pypoetry/virtualenvs/deepl-mg71yGZ3-py3.12/bin/pytest(dns block)/home/REDACTED/.cache/pypoetry/virtualenvs/deepl-mg71yGZ3-py3.12/bin/pytest /home/REDACTED/.cache/pypoetry/virtualenvs/deepl-mg71yGZ3-py3.12/bin/pytest -q tests/test_general.py tests/test_glossary.py tests/test_multilingual_glossary.py tests/test_rephrase_text.py tests/test_style_rules.py tests/test_translate_document.py tests/test_translate_text.py(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
The GitHub Actions job in repository
AKB0700/deepl-pythonis failing because the pytest suite runs without a configuredDEEPL_AUTH_KEY, but many tests instantiatedeepl.Translatorthrough shared fixtures that pass through an empty auth key. This causesValueError: auth_key must not be emptyto be raised fromdeepl/translator.pyduring test setup.Please create a pull request that fixes the failing CI job.
Constraints and expectations:
deepl/translator.pythat rejects an empty auth key.translatoranddeepl_clientfixtures intests/conftest.py, since both are backed by the same auth configuration path.Relevant failure details:
.github/workflows/python-package.ymltests/test_general.py,tests/test_glossary.py,tests/test_multilingual_glossary.py,tests/test_rephrase_text.py,tests/test_style_rules.py,tests/test_translate_document.py, andtests/test_translate_text.py.ValueError: auth_key must not be emptytests/conftest.pycalling intodeepl.Translator(...).Please implement the fix and open a PR with a concise title and summary.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: Root cause: the CI job is running the full pytest suite without providing a DeepL auth key, but many tests create a real
Translatorfrom the default config path, andTranslator.__init__()hard-fails on an empty key.Key evidence:
ValueError: auth_key must not be empty.deepl/translator.pyat lines 95–96.translatorfixture pullsauth_keyfrom env-backed config and passes it through directly intests/conftest.pylines 176–180, via_make_translator()intests/conftest.pylines 138–154.DEEPL_AUTH_KEYbefore runningpoetry run pytestin.github/workflows/python-package.ymllines 37–39.Solution
Use one of these two fixes, depending on the intended CI behavior:
Preferred fix: only run integration tests when a key is available
These tests clearly require external credentials / server access, so gate them in CI.
Update the workflow
If the secret is not always configured, split tests so unit tests always run and integration tests only run when the secret exists.
Example:
Better test-suite fix: skip auth-dependent tests when no key is configured
Right now, many tests are not marked as requiring real credentials even though they use the shared
translatorfixture. That causes hard failures instead of skips.Add a guard in the
translatorfixture intests/conftest.py:Do the same for
deepl_clientif needed: