Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Dec 16, 2025

Store Auditor reference in Middleware struct to enable proper cleanup. Update Close() to call Auditor.Close() for file-based logging. Use NewAuditorWithTransport directly instead of CreateMiddlewareWithTransport.

This ensures audit log file handles are properly closed when the runner shuts down, preventing resource leaks and ensuring logs are flushed.

Store Auditor reference in Middleware struct to enable proper cleanup.
Update Close() to call Auditor.Close() for file-based logging.
Use NewAuditorWithTransport directly instead of CreateMiddlewareWithTransport.

This ensures audit log file handles are properly closed when the runner
shuts down, preventing resource leaks and ensuring logs are flushed.
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Dec 16, 2025
Delete CreateMiddlewareWithTransport and GetMiddlewareFromFile functions
along with their tests. These functions had a design flaw where they
created an Auditor but only returned the middleware function, making it
impossible for callers to close file handles.

The CreateMiddleware factory now calls NewAuditorWithTransport directly,
making these wrapper functions unnecessary.
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Dec 16, 2025
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.81%. Comparing base (d265b0b) to head (ad1d879).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/audit/middleware.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3074      +/-   ##
==========================================
- Coverage   56.85%   56.81%   -0.04%     
==========================================
  Files         335      335              
  Lines       33474    33468       -6     
==========================================
- Hits        19030    19015      -15     
- Misses      12854    12868      +14     
+ Partials     1590     1585       -5     

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants