[WEB-5054] observability: index no_tools_found discriminators as Sentry tags#222
Merged
Merged
Conversation
vigneshsubbiah16
left a comment
Contributor
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
0 findings — 0 high-confidence, 0 to triage. Reviewers: Cursor, Claude, Semgrep, Gitleaks.
✅ Security consensus: no issues found. (reviewers: Cursor, Claude, Semgrep, Gitleaks)
🤖 consensus review · reviewers: Cursor,Claude,Semgrep,Gitleaks · head 64be64c7 · 2026-07-03T11:10Z
Promote is_root, used_fallback_user, homes_enumerated and users_scanned
from the event's unindexed `extra` into _SENTRY_TAG_KEYS so the
DISCOVERY-TOOL-SCRIPT-17 ("Discovery found no tools") population becomes
queryable/aggregatable in Sentry: root vs non-root scans, and
enumeration-miss (homes_enumerated==0) vs genuinely-empty devices.
All four are low-cardinality (2 bools + small ints). duration_ms is
deliberately left in `extra` (high cardinality). The tag-builder's
`if k in ctx` guard keeps this safe where a key is absent (is_root is
POSIX-only). No behavior change; observability-only; forward-only tagging.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64be64c to
aba07c2
Compare
MohamedAklamaash
approved these changes
Jul 3, 2026
Contributor
🛡️ Automated Security Review (consensus)0 findings — 0 high-confidence, 0 to triage. Reviewers: Lead, Claude, Semgrep, Gitleaks. ✅ Security consensus: no issues found. (reviewers: Lead, Claude, Semgrep, Gitleaks) 🤖 consensus review · reviewers: Cursor,Claude,Semgrep,Gitleaks · head |
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
is_root,used_fallback_user,homes_enumerated,users_scanned— from theno_tools_foundevent's unindexedextrainto_SENTRY_TAG_KEYS, so they become queryable/aggregatable Sentry tags.report_to_sentrylogic or Sentry grouping/fingerprint. One file, +8 lines.Why
Sentry issue DISCOVERY-TOOL-SCRIPT-17 (
RuntimeError: Discovery found no tools, level=warning — telemetry, not a crash) currently fuses several populations into one issue, and we cannot tell them apart because the disambiguating fields aren't indexed:is_rootmatters because under root thewhich-on-PATH backstop for CLI tools is disabled, a known narrow false-negative class.homes_enumerated==0/used_fallback_user==true) vs genuinely-empty device — the WEB-4956 discriminator that's meant to separate a scanner failure from a legitimately empty laptop.These fields are already collected in the event context; they just sit in
extrawhere Sentry can't aggregate them (verified live — they return empty in Sentry aggregate queries). This one-tuple change makes the population sliceable so we can quantify the real size of the root-mode blind spot before deciding whether the detection fix is worth building.Changes
scripts/coding_discovery_tools/utils.py: add the four keys to_SENTRY_TAG_KEYS+ a comment documenting the low-cardinality invariant and whyduration_msis deliberately excluded (high cardinality → stays inextra).Notes / scope
main(the fleet runsmainviainstall.sh; theno_tools_foundemission from [WEB-4956] Add no_tools_found Sentry event to diagnose empty discovery scans #215/Drop CI/local-run noise from production Sentry (DISCOVERY-TOOL-SCRIPT-17/-13/-12/-D) #216 lives onmain, notstaging).phase/fingerprint split that would give the enumeration-miss case its own Sentry issue/alert, and the root-mode CLI detection fix. Both are follow-ups this PR unblocks by giving us the numbers.Test plan
_SENTRY_TAG_KEYSchange is a 1:1 match to the keys theno_tools_foundemission puts in ctx (ai_tools_discovery.py);if k in ctxguard keepsis_rootsafe on Windows (absent → skipped).report_to_sentry+TestNoToolsSentryEventsuites pass (no test asserts on_SENTRY_TAG_KEYS, so nothing breaks).🤖 Generated with Claude Code
Note
Low Risk
Metadata-only tuple change; no runtime behavior or data-path changes beyond Sentry tag indexing.
Overview
Extends
_SENTRY_TAG_KEYSso four fields already on theno_tools_foundSentry context—is_root,used_fallback_user,homes_enumerated,users_scanned—are copied into indexed tags byreport_to_sentry, not only left inextra.A short comment documents the low-cardinality rule and that
duration_msstays unindexed. No change to scan logic, event emission, or Sentry transport; the existingif k in ctxguard still limits these tags to events that supply those keys.Reviewed by Cursor Bugbot for commit aba07c2. Bugbot is set up for automated code reviews on this repo. Configure here.
Greptile Summary
This PR promotes four fields —
is_root,used_fallback_user,homes_enumerated, andusers_scanned— from Sentry's unindexedextrainto_SENTRY_TAG_KEYSso they become queryable/aggregatable Sentry tags on theno_tools_foundwarning event. The change is observability-only: no scan logic, event emission, or grouping behavior is modified._SENTRY_TAG_KEYStuple inutils.py; the existingif k in ctxguard inreport_to_sentrysafely handles the Windows case whereis_rootis absent from context.duration_ms(high cardinality) from tags.Confidence Score: 5/5
Safe to merge — a single tuple addition with no scan logic, emission, or grouping changes.
The change is a one-line tuple extension plus a comment. The existing
if k in ctxguard inreport_to_sentrycorrectly handles the Windows case whereis_rootis absent, and all four new keys are already present on theno_tools_foundcontext at emission time. No new data paths, no new curl calls, no dedup or circuit-breaker interaction.No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[no_tools_found block\nai_tools_discovery.py:3257] --> B[Build no_tools_ctx\nphase / homes_enumerated /\nusers_scanned / used_fallback_user] B --> C{hasattr os getuid?} C -- Yes\nLinux/macOS --> D[Add is_root to ctx] C -- No\nWindows --> E[Skip is_root] D & E --> F[report_to_sentry\npriority=True] F --> G[Build tags dict\nk in _SENTRY_TAG_KEYS AND k in ctx] G --> H[Sentry tags PROMOTED by this PR:\nis_root / used_fallback_user /\nhomes_enumerated / users_scanned] G --> I[Sentry extra\nall ctx keys incl. duration_ms]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[no_tools_found block\nai_tools_discovery.py:3257] --> B[Build no_tools_ctx\nphase / homes_enumerated /\nusers_scanned / used_fallback_user] B --> C{hasattr os getuid?} C -- Yes\nLinux/macOS --> D[Add is_root to ctx] C -- No\nWindows --> E[Skip is_root] D & E --> F[report_to_sentry\npriority=True] F --> G[Build tags dict\nk in _SENTRY_TAG_KEYS AND k in ctx] G --> H[Sentry tags PROMOTED by this PR:\nis_root / used_fallback_user /\nhomes_enumerated / users_scanned] G --> I[Sentry extra\nall ctx keys incl. duration_ms]Reviews (2): Last reviewed commit: "observability: index no_tools_found disc..." | Re-trigger Greptile