Draft
Conversation
…ise)
The azure-pylint-guidelines-checker (v0.5.7) and pylint (v4.0.4) used by the
Azure SDK Build Analyze pipeline started flagging recently-introduced code in
azure-cosmos with the following error categories:
- C4766 do-not-log-exceptions-if-not-debug
- C4762 do-not-log-raised-errors
Fixes (production source under azure/cosmos/ only):
* _read_items_helper.py: Lower the exception log in the parallel-execute
error path to DEBUG (the exception is re-raised; callers log details).
* _cosmos_http_logging_policy.py: Move the existing
'pylint: disable=do-not-log-exceptions-if-not-debug' suppression onto the
line pylint actually reports (the logger.warning call) for the two
failed-to-log fallback handlers. No behavioural change.
* _global_endpoint_manager.py / aio/_global_endpoint_manager_async.py:
Background health-check task failures now log at DEBUG (with exc_info)
instead of ERROR. The exception is intentionally swallowed so background
failures cannot affect foreground request flow; debug-level logging
still preserves diagnostics.
* _query_advisor/_query_advice.py: Lower the response-header parse-failure
log to DEBUG; the function returns None on failure and the caller treats
advice as optional, so a warning is not warranted.
* _routing/routing_map_provider.py and _routing/aio/routing_map_provider.py:
Drop the try/except-raise block around _ReadPartitionKeyRanges that only
logged-and-re-raised. The CosmosHttpResponseError now propagates unchanged
to the caller (documented via inline comment + existing :raises: docstring
in the async variant). Removes both C4762 and the resulting W0706
(try-except-raise) and the now-unused CosmosHttpResponseError import.
Validation:
cd sdk/cosmos/azure-cosmos
pylint --rcfile=../../../pylintrc azure/cosmos # 10.00/10
pylint --rcfile=../../../eng/pylintrc azure/cosmos # 10.00/10
python -c 'import azure.cosmos' # ok
No '# pylint: disable=...' was added that did not already exist in the
surrounding code; the only disable adjustments are repositioning existing
suppressions onto the line pylint actually flags.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
The
Build Analyze(pylint) job forsdk/cosmos/azure-cosmoswas failing with 9 new pylint errors introduced by recent commits (between 2025-08 and 2026-04). All flagged production code is inazure/cosmos/. This PR applies minimal, surgical fixes — no behavioural changes, no test edits.Errors fixed (by category)
C4766do-not-log-exceptions-if-not-debug_read_items_helper.py,_cosmos_http_logging_policy.py(×2),_global_endpoint_manager.py,_query_advisor/_query_advice.py,_routing/routing_map_provider.py,_routing/aio/routing_map_provider.py,aio/_global_endpoint_manager_async.pyC4762do-not-log-raised-errors_routing/routing_map_provider.py,_routing/aio/routing_map_provider.pyFix strategy (one line per category)
routing_map_provider.py(sync + async) — removed thetry/except CosmosHttpResponseError: log; raiseblock around_ReadPartitionKeyRanges. The exception now propagates unchanged to the caller (which is responsible for logging). This also fixes the resultingW0706 try-except-raiseand removes a now-unusedCosmosHttpResponseErrorimport._global_endpoint_manager{,_async}.py— lowered the swallowed background-thread exception log fromerror(..., exc_info=True)todebug(..., exc_info=True). Foreground request flow is unaffected; debug logging still preserves diagnostics._read_items_helper.py— lowered the parallel-execute exception log todebug(the exception is re-raised on the next line, so callers can log the full detail)._query_advice.py— lowered todebug(the function returnsNoneon failure and the caller treats advice as optional)._cosmos_http_logging_policy.py— the existing# pylint: disable=do-not-log-exceptions-if-not-debugsuppression was on the wrong physical line (the trailing argument line) so pylint did not honour it. Moved the suppression to the line pylint actually reports (thelogger.warning(...)call). No behavioural change.Disable comments
Per the task constraints, no new
# pylint: disable=...comments were added. The only adjustments to pylint suppressions are repositioning the two existingdo-not-log-exceptions-if-not-debugdisables in_cosmos_http_logging_policy.pyonto the line pylint actually flags.Validation
Both pylint configurations report
10.00/10after the fix; baselinemainreports9.99/10with 9 errors (the ones fixed here). Tests undertests/were intentionally not modified — pre-existing test/sample warnings (e.g.wrong-import-order,broad-exception-caught,no-name-in-module) are unrelated to this PR's scope and are only checked by the optionalnext-pylintjob's tests/samples sub-runs.Out of scope / not changed
tests/— only checked bynext-pylint --next=True(optional/weekly), not by the standardBuild Analyzejob. Pre-existing issues left untouched.samples/— same as above.