Skip to content

fix(gooddata-eval): check internal_recipients in alert recipients comparison - #1702

Open
Tomkess wants to merge 3 commits into
masterfrom
fix/alert-check-internal-recipients
Open

fix(gooddata-eval): check internal_recipients in alert recipients comparison#1702
Tomkess wants to merge 3 commits into
masterfrom
fix/alert-check-internal-recipients

Conversation

@Tomkess

@Tomkess Tomkess commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

create_metric_alert addresses a notification one of two ways:

  • recipients / external_recipients — raw email addresses, when the channel can send externally.
  • internal_recipients — internal GoodData user ids (never emails), when the channel is restricted to workspace-registered users.

_check_recipients only ever reads recipients/external_recipients. Any alert delivered the internal way always fails this check, regardless of what the fixture expects, because the code compares against a key that's never populated for that delivery path.

Confirmed live against a real workspace whose email channel only allows internal users: a real, correctly-delivered alert with

internal_recipients: ['user.<uuid>']

still scored recipients_correct=False.

Same category of gap as #1699 (alert_proposals as a confirmation signal) — the evaluator hadn't been taught to read a real tool-response shape yet.

Changes

  • _check_recipients gains an optional sdk param. When the plain email/external comparison fails and internal_recipients is present, it resolves the expected email(s) to internal user id(s) via the Users entities API (GET /entities/users?filter=email==...) and compares against that instead.
  • Resolution is lazy — only triggered when the cheap comparison already failed and internal_recipients is actually present, so no unconditional network call lands on the hot path. This matters because the existing run_agentic_alert_skill tests never mock GoodDataSdk (only ChatClient) — an eager/unconditional lookup would have broken them.
  • 5 new unit tests: external-path unaffected (no sdk needed), internal match via resolved id, internal mismatch still fails, no-sdk graceful fail, lookup-error graceful fail.

Test plan

  • New tests reproduce the gap against the pre-fix signature (TypeError on the added sdk kwarg) before the fix, pass after.
  • Full gooddata-eval suite: 247 passed, same 9 pre-existing failures on master too (missing openai extra in this env, unrelated) — confirmed via git stash on master.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved alert recipient validation for alerts sent to internal users.
    • Recipient checks now support matching internal user IDs resolved through the SDK.
    • External recipient matching remains supported, with lookup failures handled gracefully.

…parison

create_metric_alert addresses a notification one of two ways: `recipients`/
`external_recipients` (raw email addresses) when the channel can send
externally, or `internal_recipients` (internal GoodData user ids, never
emails) when the channel is restricted to workspace-registered users.

_check_recipients only ever read recipients/external_recipients, so any
alert delivered the internal way always failed this check regardless of
what the fixture expected -- confirmed live: a real, correctly-delivered
alert with internal_recipients=['user.<uuid>'] still scored
recipients_correct=False, because the code was comparing against a key
that's never populated for that delivery path.

Resolves the expected email to its internal user id via the Users entities
API (GET /entities/users?filter=email==...), lazily -- only when the plain
comparison already failed and internal_recipients is actually present, so
no unconditional network call is added to the hot path (existing
run_agentic_alert_skill tests never mock GoodDataSdk, only ChatClient).
Same shape of gap as #1699 (alert_proposals as a confirmation signal):
gooddata-eval's evaluator hadn't been taught to read a real tool-response
shape yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Tomkess
Tomkess requested review from hkad98, lupko and pcerny as code owners August 4, 2026 07:27
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Tomkess, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b4c263d1-e8b8-4204-9304-460798fa46c7

📥 Commits

Reviewing files that changed from the base of the PR and between 679076d and ce5df30.

📒 Files selected for processing (2)
  • packages/gooddata-eval/src/gooddata_eval/core/agentic/alert_skill.py
  • packages/gooddata-eval/tests/test_agentic_alert_skill.py
📝 Walkthrough

Walkthrough

Alert recipient validation now supports external email matches and internal GoodData user IDs. The evaluator passes the SDK for ID resolution. Tests cover matches, mismatches, missing SDKs, and lookup failures.

Changes

Alert recipient validation

Layer / File(s) Summary
Recipient matching and SDK wiring
packages/gooddata-eval/src/gooddata_eval/core/agentic/alert_skill.py
The validator resolves expected emails to internal user IDs when an SDK is available. It accepts exact external matches or overlapping internal IDs.
Recipient validation coverage
packages/gooddata-eval/tests/test_agentic_alert_skill.py
Tests cover external matches, internal ID resolution, mismatches, missing SDKs, and lookup failures.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: hkad98, lupko, pcerny

Poem

A rabbit checks each alert with care,
Matching emails here and IDs there.
If lookups fail, the check stays calm,
Tests keep the pathway safe from harm.
Hop, hop—the recipients align!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: validating alert recipients through internal_recipients.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/gooddata-eval/tests/test_agentic_alert_skill.py`:
- Around line 68-72: Update
test_check_recipients_matches_external_recipients_without_sdk to pass a mock SDK
object, then assert its get_all_entities_users method was not called while
retaining the direct recipient-match assertion, so the fast path verifies no
user lookup occurs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3daa5727-084a-4e5d-a0f0-6041480bac56

📥 Commits

Reviewing files that changed from the base of the PR and between acfcc1a and 679076d.

📒 Files selected for processing (2)
  • packages/gooddata-eval/src/gooddata_eval/core/agentic/alert_skill.py
  • packages/gooddata-eval/tests/test_agentic_alert_skill.py

Comment thread packages/gooddata-eval/tests/test_agentic_alert_skill.py Outdated
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.35%. Comparing base (acfcc1a) to head (ce5df30).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1702      +/-   ##
==========================================
+ Coverage   78.30%   78.35%   +0.05%     
==========================================
  Files         271      271              
  Lines       18689    18705      +16     
==========================================
+ Hits        14634    14656      +22     
+ Misses       4055     4049       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Tomkess added 2 commits August 4, 2026 09:34
CodeRabbit review: without an sdk arg, the test couldn't catch a
regression where a Users lookup runs before the direct recipient
match. Pass a mock sdk and assert get_all_entities_users is not
called.
CI's format-check job was failing since these files predated the
project's line-length config. Reformat to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant