-
Notifications
You must be signed in to change notification settings - Fork 37
🐛 fix assessment risk and confidence when listing applications. #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Jeff Ortel <[email protected]>
WalkthroughAdds a local byte-slice field to hold JSON-serialized assessment sections in the List query result, selects at.Sections into it, and unmarshals into model.Assessment.Sections when an AssessmentId exists. Errors from unmarshalling are ignored. No exported API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant API as Application List (API)
participant DB as Database
Client->>API: List applications
API->>DB: SELECT ..., at.Sections AS AssessmentSections, ...
DB-->>API: Rows with AssessmentId, QuestionnaireId, AssessmentSections
rect rgba(220,245,255,0.5)
note over API: Build response
API->>API: If AssessmentId != nil<br/>json.Unmarshal(AssessmentSections) -> Assessment.Sections<br/>(ignore error)
end
API-->>Client: Application list (includes Assessment with Sections if present)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
| PlatformName string | ||
| ReviewId uint | ||
| AssessmentId uint | ||
| AssessmentSections []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hint: just AssessmentSections added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
api/application.go (4)
205-206: Good call: carry Sections through the List projection.Adding AssessmentSections to the M projection is the right minimal data to enable risk/confidence resolution in List without heavy preloads. Consider using json.RawMessage for slightly better intent signaling (alias of []byte) but not required.
- AssessmentSections []byte + AssessmentSections json.RawMessage
228-228: Selecting at.Sections into an alias is correct; consider null-proofing at the SQL layer (optional).If at.Sections can be NULL, Unmarshal(nil, ...) returns "unexpected end of JSON input". You’re guarding by requiring AssessmentId > 0, but Sections might still be NULL. Optionally COALESCE to an empty array/object to avoid nils (PostgreSQL example shown).
- "at.Sections AssessmentSections", + "COALESCE(at.Sections, '[]'::jsonb) AssessmentSections",If DB portability matters, keep as-is and guard before unmarshalling (see next comment).
299-305: Don’t discard JSON errors; guard and fail soft.Swallowing Unmarshal errors can silently regress back to "Unknown" risk. Guard for empty/nil payloads and, if decode fails, skip populating Sections but keep the request alive. This improves debuggability without breaking List responses.
- _ = json.Unmarshal(m.AssessmentSections, &ref.Sections) + if len(m.AssessmentSections) > 0 { + if err := json.Unmarshal(m.AssessmentSections, &ref.Sections); err != nil { + // soft-fail: keep Sections empty so resolver degrades gracefully. + // Optional: add debug logging if a logger is available. + } + }If the codebase prefers the migration/json shim for consistency:
- if len(m.AssessmentSections) > 0 { - if err := json.Unmarshal(m.AssessmentSections, &ref.Sections); err != nil { + if len(m.AssessmentSections) > 0 { + if err := jsonpkg.Unmarshal(m.AssessmentSections, &ref.Sections); err != nil {…and add at the top:
- "encoding/json" + "encoding/json" + jsonpkg "github.com/konveyor/tackle2-hub/migration/json"
171-177: Sanity check: this should address #891 end-to-end. Please verify UI paths.With Sections now loaded in List, Application.WithResolver should compute Assessed/Risk/Confidence correctly for listings and the drawer. Please re-run the repro steps from issue #891 and confirm:
- Applications list shows correct Risk/Confidence
- Application drawer shows the same values
- Reports tab remains consistent
I can help add a focused API test to assert that GET /applications includes non-"Unknown" risk after creating an assessment via POST /applications/{id}/assessments. Want me to draft that?
Also applies to: 333-346
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
api/application.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
api/application.go (1)
migration/json/pkg.go (1)
Unmarshal(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test-unit
- GitHub Check: build
The resolvers expect the
Application.Assessments[].Sectionsto be populated.This works for Get() because it uses db.Fetch() with clause.Associations which fetches the entire nested Assessment object. List() uses a a custom join for performance and memory footprint.
This is a regression introduced by #789 RE: application list performance and memory footprint. OPTIMIZATION.
closes #891