Repository navigation
Conversation
Signed-off-by: Ahmed Gouda <ahmed.gouda@owasp.org>
Summary by CodeRabbit
WalkthroughAdds batched dataloaders for entity-channel external IDs and names. Registers them in the OWASP dataloader collection and updates ChangesEntity channel optimization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feature/graphql-dataloaders #5395 +/- ##
============================================================
Coverage 98.84% 98.84%
============================================================
Files 554 555 +1
Lines 17594 17614 +20
Branches 2483 2483
============================================================
+ Hits 17391 17411 +20
Misses 101 101
Partials 102 102
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 `@backend/src/apps/owasp/api/internal/dataloaders/entity_channel.py`:
- Around line 16-36: The loader function
_load_channel_field_by_entity_channel_id lacks focused coverage. Add tests
verifying results preserve input ID order, return None for missing IDs, and
return None for non-Conversation channels; also assert the expected fixed query
count when loading multiple IDs in one batch to preserve the batching
optimization.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 80c6c594-d2dc-4627-ba87-5515499ac8a7
📒 Files selected for processing (3)
backend/src/apps/owasp/api/internal/dataloaders/__init__.pybackend/src/apps/owasp/api/internal/dataloaders/entity_channel.pybackend/src/apps/owasp/api/internal/nodes/entity_channel.py
There was a problem hiding this comment.
3 issues found across 3 files
Confidence score: 3/5
- In
backend/src/apps/owasp/api/internal/dataloaders/entity_channel.py, empty stored channel names now come back as GraphQLnullinstead of"", which can break clients that rely on the existing field contract and null/empty-string semantics—preserve empty strings and returnNoneonly for truly missing rows. - In
backend/src/apps/owasp/api/internal/nodes/entity_channel.py, resolver signatures now requireinfoand async awaiting, so existingEntityChannelNodetests fail and CI stability is at risk until they’re updated—add async test coverage with anowasp_dataloaderscontext and assert loader/key usage. - The new batch-query dataloader path in
backend/src/apps/owasp/api/internal/dataloaders/entity_channel.py(filtering, subquery annotation, key reordering) has no unit tests, leaving ordering and mapping regressions hard to catch—add focused tests for content-type filtering and deterministic key-to-result alignment.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/src/apps/owasp/api/internal/nodes/entity_channel.py">
<violation number="1" location="backend/src/apps/owasp/api/internal/nodes/entity_channel.py:26">
P2: Existing EntityChannelNode resolver tests fail because these methods now require `info` and must be awaited; update them to provide an `owasp_dataloaders` context and assert the requested loader/key. This keeps CI passing and covers the new batching path.
(Based on your team's feedback about adding or updating tests for new logic.)</violation>
</file>
<file name="backend/src/apps/owasp/api/internal/dataloaders/entity_channel.py">
<violation number="1" location="backend/src/apps/owasp/api/internal/dataloaders/entity_channel.py:32">
P2: Channels with an empty stored name now resolve as GraphQL `null` rather than `""`, changing the existing field contract during this optimization. Preserve empty strings and let only missing query results remain `None`.</violation>
<violation number="2" location="backend/src/apps/owasp/api/internal/dataloaders/entity_channel.py:39">
P3: This PR adds a new dataloader module with real batch-query logic (content-type filtering, correlated Subquery annotation, and result reordering via get_result_by_keys), but it ships without any unit tests. Every sibling dataloader added under apps/owasp/api/internal/dataloaders (chapter, committee, member_snapshot, project, snapshot, board_of_directors) has a corresponding test file in backend/tests/unit/apps/owasp/api/internal/dataloaders/. Adding an entity_channel_test.py covering load_external_id_by_entity_channel_id and load_name_by_entity_channel_id (including the ordering/no-match and empty-channel cases) would keep this new behavior protected against regressions and align it with the existing pattern.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Signed-off-by: Ahmed Gouda <ahmed.gouda@owasp.org>
…or the regsitration tests PR Signed-off-by: Ahmed Gouda <ahmed.gouda@owasp.org>
22ba58f
|
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Confidence score: 4/5
- In
backend/tests/unit/apps/owasp/api/internal/dataloaders/dataloaders_test.py, removing the entity-channel keys fromEXPECTED_LOADER_KEYSwhileget_owasp_dataloaders()still includes them can let registration drift go undetected, weakening coverage and masking a future regression in dataloader wiring — align the expected keys with currentget_entity_channel_loaders()behavior (or update production registration intentionally and consistently).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/apps/owasp/api/internal/dataloaders/dataloaders_test.py">
<violation number="1">
P3: This change removes the two entity-channel loaders from the aggregated registration test (EXPECTED_LOADER_KEYS) while get_owasp_dataloaders() still registers them via get_entity_channel_loaders() at this PR head. As a result, the test no longer verifies that EXTERNAL_ID_BY_ENTITY_CHANNEL_ID_LOADER and NAME_BY_ENTITY_CHANNEL_ID_LOADER are included in the aggregated loader mapping, so a future removal of the get_entity_channel_loaders() call from the aggregator would go uncaught. The commit message indicates the loaders' removal is intended but deferred to a follow-up registration-tests PR; until the loaders are actually removed from entity_channel.py and __init__.py, consider keeping these keys in EXPECTED_LOADER_KEYS so the test stays consistent with the module, and drop them in the same change that removes the loaders.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
d8c8439
into
OWASP:feature/graphql-dataloaders



Proposed change
Resolves #5286
Optimized EntityChannelNode
Checklist