Fix: Include custom type summaries in parent summary
Context
The type: custom feature (added in !364 (merged)) allows summaries to include external data without fetching GitLab resources. However, custom type summaries were not appearing in parent summary outputs due to incorrect filtering logic.
What's in this MR?
Bug Fix:
- Changed filtering logic in
summary_policy.rbto usecontent_available?method - Custom type summaries now properly included in parent summary output
Code Quality Improvements:
- Added
content_available?method to determine if summary should be included in parent - Added
title_present?helper that returns explicit boolean (avoids!!pattern) - Kept
valid?method name (Ruby idiom - describes object state, not action) - Inlined
any_resources?method (only used once) - Renamed
issuestochild_summariesfor clarity
Testing:
- Added comprehensive integration tests in
spec/integration/custom_type_in_parent_summary_spec.rb - Tests verify custom summaries are included (even with 0 resources)
- Tests verify regular summaries without resources are excluded
- Updated existing unit tests
CI Improvement:
- Updated lefthook to run full test suite on pre-push to catch integration issues
Proof of Work
Create test policy file:
cat > test-custom-type-fix.yml <<'EOF'
resource_rules:
issues:
summaries:
- name: Test Parent Summary
actions:
summarize:
title: "Test: Custom Type in Parent Summary"
summary: |
# Test Results
{{items}}
rules:
- name: Custom Type Summary
type: custom
actions:
summarize:
title: "External Data"
summary: |
## External Data Source
This content comes from a custom type summary (no GitLab resources fetched).
- Item 1: Test data
- Item 2: More test data
- Status: Working ✓
- name: Regular Summary with Resources
conditions:
state: opened
labels:
- bug
limits:
most_recent: 2
actions:
summarize:
item: "- {{title}} ({{web_url}})"
summary: |
## Recent Bug Issues
{{items}}
EOF
Update Gemfile to use local gitlab-triage with this fix:
# In your triage project (e.g., triage-ops)
sed -i.bak 's|gem "gitlab-triage".*|gem "gitlab-triage", path: "../gitlab-triage"|' Gemfile
bundle install
Run the test:
bundle exec gitlab-triage --dry-run \
--token $GITLAB_API_PRIVATE_TOKEN \
--source-id gitlab-org/gitlab \
--policies-file test-custom-type-fix.yml
Expected output (showing both summaries included):
Processing summary: **Test Parent Summary**
Gathering resources for rule: **Custom Type Summary**
* Skipping resource fetch for custom type rule
Gathering resources for rule: **Regular Summary with Resources**
* Found 33 resources...
* Filtering resources...
* Total after filtering: 33 resources
* Limiting resources...
* Total after limiting: 2 resources
The following issue would be created in project `gitlab-org/gitlab`:
>>>
* Title: Test: Custom Type in Parent Summary
* Description: # Test Results
## External Data Source
This content comes from a custom type summary (no GitLab resources fetched).
- Item 1: Test data
- Item 2: More test data
- Status: Working ✓
## Recent Bug Issues
- Duo Agent Platform accessible without Duo Core prerequisite (https://gitlab.com/...)
- Fix type inconsistency between agent_platform_sessions table (https://gitlab.com/...)
>>>
Result: Parent summary correctly includes both the custom type summary (External Data Source) and the regular summary (Recent Bug Issues).
Cleanup:
rm test-custom-type-fix.yml
git checkout Gemfile Gemfile.lock
Related
- Original MR adding
type: customsupport: !364 (merged) - Proof of work tests: triage-ops!3812
- Real-world usage: triage-ops!3804
Edited by David Dieulivol