fix: testops_multi xdist run_id handoff + mask api token in config log (commons part)#498
Merged
Merged
Conversation
…debug log
In testops_multi mode the controller produces a {project_code: run_id}
dict. The xdist worker boundary previously called
QaseTestOpsMulti.set_run_id() with one positional argument, but the
multi setter requires (project_code, run_id), so workers crashed with
"missing 1 required positional argument: 'run_id'" and silently fell
back to local report, dropping results from TestOps.
Add QaseTestOpsMulti.set_run_ids(run_ids: Dict[str, Union[str, int]])
that seeds every known project at once, and route
QaseCoreReporter.set_run_id() to dispatch dict input through it. The
single-project (project_code, run_id) API is unchanged.
Also mask the api token in the QaseCoreReporter debug config dump.
str(self.config) serialised testops.api.token in clear text, so any
debug log shared with support or pasted into an issue leaked the
customer's API key. Add qase.commons.util.token_masker mirroring the
qase-javascript-commons/src/utils/token-masker.ts contract: tokens of
8+ chars render as abc****wxyz, tokens of 7 chars or fewer are fully
hidden, and a serialisation failure falls back to plain str(config) so
the masker can never silence debug output.
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.
Commons-only half of the two-PR split. Pytest counterpart will land in a separate PR pinning this commons release.
Bundles two fixes in
qase-python-commons5.1.2:Fix 1 —
testops_multirun_id handoff (commons side)Symptom (reported by customer running
pytest -n 2intestops_multimode)Workers crashed in xdist, silently fell back to the local report reporter, and dropped results from TestOps.
Root cause
The xdist controller produces
Dict[project_code, run_id]. The pytest worker boundary calledQaseCoreReporter.set_run_id(run_id)with that dict shape, but the innerQaseTestOpsMulti.set_run_id(project_code, run_id)requires two positional arguments — so workers crashed with aTypeErrorthat the core reporter swallowed and routed through fallback.Fix (in this PR)
QaseTestOpsMulti.set_run_ids(run_ids: Dict[str, Union[str, int]])— bulk setter that seeds every known project at once, warns on unknown codes.QaseCoreReporter.set_run_id(run_id)now dispatchesdictinput toset_run_ids(viahasattrso non-multi reporters never see a dict).QaseTestOpsMulti.set_run_id(project_code, run_id)API is unchanged for direct callers.The pytest-side change (JSON serialisation of the lock file +
load_run_from_lockdispatch) lives in the companion pytest PR.Fix 2 — Mask API token in debug config dump
Symptom
QaseCoreReporter.__init__logged the full config viastr(self.config), which serialisedtestops.api.tokenin clear text. Any debug log shared with support or pasted into an issue leaked the customer's API key.Fix
qase.commons.util.token_maskermodule mirroring the JS contract fromqase-javascript-commons/src/utils/token-masker.ts.abc****wxyz(first 3 + last 4).*.str(config)if the serialised form cannot be parsed as JSON, so a bug in the masker can never silence debug output.Test plan
set_run_idscases (bulk, string→int, unknown-project warning).QaseCoreReporter.set_run_iddispatch cases (dict →set_run_ids, scalar →set_run_id, TypeError fallback).token_maskercases (long/short token edges, defensive non-string input, sanitize roundtrip, unparseable fallback).examples/multiproject/pytestwithpytest -n 2:missing 1 required positional argumenterrors, 3× full token leak in log, 4 silent fallback JSON files.90e****ce5a, all 12 worker results land inDEVX #895/DEMO #714.Release
qase-python-commons5.1.1 → 5.1.2.Companion PR
qase-pytesthalf (lock-file JSON serialisation + dep pin toqase-python-commons~=5.1.2) ships next.