fix(servicenow-provider): fix pagination, auth, and a NameError in notify_update - #6724
Open
Prabal864 wants to merge 1 commit into
Open
fix(servicenow-provider): fix pagination, auth, and a NameError in notify_update#6724Prabal864 wants to merge 1 commit into
Prabal864 wants to merge 1 commit into
Conversation
Prabal864
force-pushed
the
fix/servicenow-provider-bugs
branch
from
August 21, 2026 20:57
1abdea9 to
5932b43
Compare
…tify_update Four independent bugs in the ServiceNow provider: - _query always reset sysparm_offset to 0 instead of forwarding the caller's value, so _get_incidents' pagination loop kept re-fetching page 1 forever whenever there were >= 1 page of incidents. - _notify_update's auth selection was inverted (used basic auth only when an access token was present, i.e. the opposite of every other auth site in this file), so OAuth-configured instances silently sent basic auth on ticket updates instead of the bearer token. - _notify_update's failure branch called resp.raise_for_status() where resp was never assigned, raising NameError instead of the intended HTTPError. - pull_topology's CMDB fields list was missing a comma between "owned_by.name" and "manufacturer.name", so Python concatenated them into a single nonexistent field name and neither value was ever returned. Fixes keephq#6723
Prabal864
force-pushed
the
fix/servicenow-provider-bugs
branch
from
August 23, 2026 07:58
5932b43 to
6a245e5
Compare
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.
What
Fixes #6723.
Four independent bugs in
keep/providers/servicenow_provider/servicenow_provider.py, all confirmed directly against the current code:_query'sif sysparm_offset: params["sysparm_offset"] = 0hardcoded0instead of forwarding the caller'ssysparm_offset._get_incidentscalls_queryin awhile Trueloop, advancingoffsetonly when a full page comes back — since every page after the first was actually still page 1, and a full page (100 items) kept coming back, this loop never terminated naturally for any instance with >= 100 incidents.NameErrorinstead ofHTTPErrorin_notify_update's failure branch —resp.raise_for_status()whererespis only ever assigned inside thestatus_code == 200branch, so theelsebranch always raisedNameErrorinstead of the real HTTP error._notify_update— its auth-tuple construction usedif self._access_tokenwhere every other auth site in this file (_query,_notify,pull_topology,_get_auth) usesif not self._access_token. This meant OAuth-configured instances got basic auth sent on ticket updates instead of (or alongside) the bearer token.pull_topology's CMDB fields list —"owned_by.name"directly followed by"manufacturer.name",with no comma between them, so Python's adjacent string-literal concatenation silently merged them into one nonexistent field ("owned_by.namemanufacturer.name"), so the ServiceNow API never returned either value.Testing
Added to
tests/test_servicenow_provider.py:TestQueryPagination— asserts a non-zerosysparm_offsetreaches the request unchanged, and that0stays0.TestNotifyUpdate— asserts basic auth is used when there's no access token, the bearer header is used (andauth=None) when there is one, and the failure path raises the realHTTPErrorinstead of crashing withNameError.TestPullTopologyFields— assertsowned_by.nameandmanufacturer.nameboth appear as separate entries in the requestedsysparm_fields.I wasn't able to run the suite in my sandbox for the same reason as my last PR here — this repo's
ContextManager(imported transitively by the provider base classes) unconditionally pulls inkeep/api/core/db.py's full dependency chain (opentelemetry, mysql-connector, etc.), and a fullpip install -e .fails on Windows regardless (uvloopdoesn't support it). I traced each fix by hand against the exact current code (line numbers/behavior confirmed viagit show/git grepagainstupstream/main) and the added tests follow this file's existingMagicMock-based fixture pattern, so they should run cleanly under CI.python -m py_compilepasses on both changed files.Note: I didn't run
black/isorton the full file since it isn't currently formatted with either onmainand CI doesn't enforce them here — didn't want to bundle an unrelated reformat into this diff. My changed lines are minimal and match the surrounding style.