feat: add public benchmark language fixtures#483
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughThis PR adds two new service fixtures (Python FastAPI and Go net/http) to the benchmark suite that implement matching login-session endpoints with audit logging, updates the suite configuration to mark them as ready, and extends test coverage to validate their wiring and presence. ChangesBenchmark Suite Fixtures & Configuration
Sequence Diagram(s)sequenceDiagram
participant Client
participant Route as /login/session POST
participant SessionService
participant SessionRepository
participant AuditLog
Client->>Route: user_id, device_id
Route->>SessionService: create_login_session
SessionService->>SessionRepository: create_login_session
SessionRepository-->>SessionService: SessionRecord (user_id:device_id)
SessionService->>AuditLog: record_login_session
AuditLog-->>SessionService: recorded
SessionService-->>Route: SessionRecord
Route-->>Client: session_id, audit_event
sequenceDiagram
participant Client
participant Handler as SessionHandler
participant SessionService
participant SessionRepository
participant LoginAudit
Client->>Handler: POST /login/session (user_id, device_id)
Handler->>SessionService: CreateLoginSession
SessionService->>SessionRepository: CreateLoginSession
SessionRepository-->>SessionService: Session
SessionService->>LoginAudit: RecordLoginSession
LoginAudit-->>SessionService: recorded
SessionService-->>Handler: Session
Handler-->>Client: JSON (session_id, audit_event)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
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
`@docs/benchmarks/suite/fixtures/go-service/internal/repository/session_repository.go`:
- Around line 15-21: The CreateLoginSession method currently builds session IDs
from userID and deviceID without validation; change its signature from
CreateLoginSession(userID string, deviceID string) Session to
CreateLoginSession(userID string, deviceID string) (Session, error), validate
that neither userID nor deviceID is empty (check in
SessionRepository.CreateLoginSession), return a non-nil error when either is
empty, and only construct Session{ID: userID + ":" + deviceID, UserID: userID,
DeviceID: deviceID} when both are present; update all callers to handle the
(Session, error) return so malformed IDs like ":" cannot be produced.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c12cdd51-8e73-460a-867a-82a1a418bf5b
📒 Files selected for processing (25)
docs/benchmarks/suite/README.mddocs/benchmarks/suite/fixtures/go-service/README.mddocs/benchmarks/suite/fixtures/go-service/cmd/api/main.godocs/benchmarks/suite/fixtures/go-service/go.moddocs/benchmarks/suite/fixtures/go-service/internal/audit/login_audit.godocs/benchmarks/suite/fixtures/go-service/internal/httpapi/session_handler.godocs/benchmarks/suite/fixtures/go-service/internal/repository/session_repository.godocs/benchmarks/suite/fixtures/go-service/internal/service/session_service.godocs/benchmarks/suite/fixtures/go-service/internal/service/session_service_test.godocs/benchmarks/suite/fixtures/python-service/README.mddocs/benchmarks/suite/fixtures/python-service/app/__init__.pydocs/benchmarks/suite/fixtures/python-service/app/audit.pydocs/benchmarks/suite/fixtures/python-service/app/main.pydocs/benchmarks/suite/fixtures/python-service/app/repositories/__init__.pydocs/benchmarks/suite/fixtures/python-service/app/repositories/session_repository.pydocs/benchmarks/suite/fixtures/python-service/app/routes/__init__.pydocs/benchmarks/suite/fixtures/python-service/app/routes/session_routes.pydocs/benchmarks/suite/fixtures/python-service/app/services/__init__.pydocs/benchmarks/suite/fixtures/python-service/app/services/session_service.pydocs/benchmarks/suite/fixtures/python-service/requirements.txtdocs/benchmarks/suite/fixtures/python-service/tests/test_session_service.pydocs/benchmarks/suite/repos.jsondocs/benchmarks/suite/tasks.jsontests/unit/benchmark-suite-docs.test.tstests/unit/benchmark-suite.test.ts
| func (r *SessionRepository) CreateLoginSession(userID string, deviceID string) Session { | ||
| return Session{ | ||
| ID: userID + ":" + deviceID, | ||
| UserID: userID, | ||
| DeviceID: deviceID, | ||
| } | ||
| } |
There was a problem hiding this comment.
Add input validation for empty strings.
The method concatenates userID and deviceID without validation. Empty strings would produce malformed session IDs like ":" or ":device", which could confuse benchmark tests or results.
🛡️ Suggested validation
func (r *SessionRepository) CreateLoginSession(userID string, deviceID string) Session {
+ if userID == "" || deviceID == "" {
+ panic("userID and deviceID must not be empty")
+ }
return Session{
ID: userID + ":" + deviceID,
UserID: userID,
DeviceID: deviceID,
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func (r *SessionRepository) CreateLoginSession(userID string, deviceID string) Session { | |
| return Session{ | |
| ID: userID + ":" + deviceID, | |
| UserID: userID, | |
| DeviceID: deviceID, | |
| } | |
| } | |
| func (r *SessionRepository) CreateLoginSession(userID string, deviceID string) Session { | |
| if userID == "" || deviceID == "" { | |
| panic("userID and deviceID must not be empty") | |
| } | |
| return Session{ | |
| ID: userID + ":" + deviceID, | |
| UserID: userID, | |
| DeviceID: deviceID, | |
| } | |
| } |
🤖 Prompt for 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.
In
`@docs/benchmarks/suite/fixtures/go-service/internal/repository/session_repository.go`
around lines 15 - 21, The CreateLoginSession method currently builds session IDs
from userID and deviceID without validation; change its signature from
CreateLoginSession(userID string, deviceID string) Session to
CreateLoginSession(userID string, deviceID string) (Session, error), validate
that neither userID nor deviceID is empty (check in
SessionRepository.CreateLoginSession), return a non-nil error when either is
empty, and only construct Session{ID: userID + ":" + deviceID, UserID: userID,
DeviceID: deviceID} when both are present; update all callers to handle the
(Session, error) return so malformed IDs like ":" cannot be produced.
Summary
Test Plan
Refs #469
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests
Chores