ECOPROJECT-5132 | feat: add assessment enhancement data endpoints - #1404
ECOPROJECT-5132 | feat: add assessment enhancement data endpoints#1404turjemantal wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Warning Review limit reached
Next review available in: 1 minute You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (29)
📝 WalkthroughWalkthroughChangesAdded GET and POST assessment enhancement-data endpoints with OpenAPI schemas and generated client/server support. Added PostgreSQL persistence, typed array conversion, service mappings, authorization-aware handlers, runtime wiring, and tests. Assessment enhancement data
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Client
participant ChiRouter
participant ServiceHandler
participant AssessmentEnhancementDataService
participant AssessmentEnhancementDataStore
Client->>ChiRouter: POST enhancement data
ChiRouter->>ServiceHandler: Validate UUID and request body
ServiceHandler->>AssessmentEnhancementDataService: SaveEnhancementData
AssessmentEnhancementDataService->>AssessmentEnhancementDataStore: Upsert enhancement data
AssessmentEnhancementDataStore-->>AssessmentEnhancementDataService: Persisted model
AssessmentEnhancementDataService-->>ServiceHandler: EnhancementData
ServiceHandler-->>Client: HTTP 200 EnhancementData
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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 `@api/v1alpha1/openapi.yaml`:
- Around line 3431-3557: Add validation tags to the generated enhancement
request types for all enum fields, nonnegative counters, and unique arrays, plus
maximum-length constraints on VsphereCoreInput.vmEncryptionPolicy and
CustomerDetailsInput.targetHardware using the project’s established limits. In
SaveAssessmentEnhancementData, validate the decoded request body after
assessment ID checks and before mapping or calling SaveEnhancementData,
returning the standard request-validation error without persisting invalid
values.
In `@api/v1alpha1/types.gen.go`:
- Around line 248-257: Add x-enum-varnames under
VMwareSubscriptionInput.level.items.enum in api/v1alpha1/openapi.yaml, assigning
explicit scoped names for each VMwareSubscriptionInputLevel value, then
regenerate api/v1alpha1/types.gen.go so the exported constants use those names
instead of generic identifiers.
In `@internal/handlers/v1alpha1/assessment_enhancement_data_test.go`:
- Around line 136-165: Extend the “overwrites previous data on second save” test
after the second SaveAssessmentEnhancementData call by invoking
GetAssessmentEnhancementData for the same assessmentID. Assert the returned
response contains the persisted deployed environment value “on_cloud,” while
retaining the existing save-response assertion.
In `@internal/service/assessment_enhancement_data.go`:
- Around line 64-213: 添加针对 enhancementDataAPIToModel 和 enhancementDataModelToAPI
的表驱动单元测试,覆盖十个可选数据段、所有 typed enum 字段、nil 字段、nil slice 以及空 slice。验证 API 到 model 及
model 到 API 的字段映射、指针和切片语义,并确保每个可选 section 的存在与缺失行为符合当前转换契约。
In `@internal/store/model/stringarray.go`:
- Around line 52-80: Fix parsePostgresArray so it preserves trailing and
standalone empty elements: track whether an element has started independently of
current.Len(), append the final element unconditionally, and retain empty quoted
values. Add table cases covering StringArray{"a", ""}, StringArray{""}, and
StringArray{"", "b"} in TestStringArrayScan and TestStringArrayRoundTrip.
In `@pkg/migrations/sql/20260730120000_assessment_enhancement_data.sql`:
- Around line 4-5: Change assessment_id in the migration to the PostgreSQL UUID
type and retain its foreign-key cascade behavior, then update the corresponding
Go model field to uuid.UUID so generated SQL and runtime types match. Review
sibling reference columns in the same migration and remove fixed VARCHAR(255)
lengths where the schema standard uses unbounded text or UUID-compatible types.
🪄 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: 38fcdb8e-df0d-4d84-a37b-39bcb9277ea7
📒 Files selected for processing (28)
api/v1alpha1/openapi.yamlapi/v1alpha1/spec.gen.goapi/v1alpha1/types.gen.gointernal/api/client/client.gen.gointernal/api/server/server.gen.gointernal/api_server/server.gointernal/handlers/v1alpha1/accounts_test.gointernal/handlers/v1alpha1/assessment_enhancement_data.gointernal/handlers/v1alpha1/assessment_enhancement_data_test.gointernal/handlers/v1alpha1/assessment_test.gointernal/handlers/v1alpha1/estimation_test.gointernal/handlers/v1alpha1/handler.gointernal/handlers/v1alpha1/job_test.gointernal/handlers/v1alpha1/partner_test.gointernal/handlers/v1alpha1/sizer_test.gointernal/handlers/v1alpha1/source_test.gointernal/service/assessment_enhancement_data.gointernal/service/eventwrap/dispatcher_test.gointernal/service/sizer_test.gointernal/service/source_test.gointernal/store/assessment_enhancement_data.gointernal/store/assessment_enhancement_data_test.gointernal/store/model/assessment_enhancement_data.gointernal/store/model/stringarray.gointernal/store/model/stringarray_test.gointernal/store/store.gopkg/migrations/migrations_test.gopkg/migrations/sql/20260730120000_assessment_enhancement_data.sql
|
@coderabbitai review |
✅ Action performedReview finished.
|
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 `@internal/service/assessment_enhancement_data_test.go`:
- Around line 61-68: Update the test cases in
internal/service/assessment_enhancement_data_test.go at lines 61-68, 105-112,
113-120, and 121-128 to use API-supported enum values: replace “staging” with
“dev”, “monitoring” with “performance_analytics”, “orchestration” with
“orchestrator”, and “compliance” with “compliance_monitoring”, including
corresponding expected assertions while preserving the existing coverage.
🪄 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: 9f693867-c1f3-498b-a789-3d610fc41d03
📒 Files selected for processing (9)
api/v1alpha1/openapi.yamlapi/v1alpha1/spec.gen.goapi/v1alpha1/types.gen.gointernal/handlers/v1alpha1/assessment_enhancement_data.gointernal/handlers/v1alpha1/assessment_enhancement_data_test.gointernal/service/assessment_enhancement_data_test.gointernal/service/sizer_test.gointernal/store/model/stringarray.gointernal/store/model/stringarray_test.go
Introduce POST and GET /api/v1/assessments/{id}/enhancement-data endpoints
to persist and retrieve user-provided VMA enhancement data that cannot be
auto-collected by Agent or RVTools.
Add request validation for enhancement data fields, fix parsePostgresArray
dropping empty-string elements, and add test coverage for the enhancement
data mapper functions, second-save persistence check, and API-supported
enum values.
Signed-off-by: Tal Turjeman <tturjema@redhat.com>
c040d3c to
b6a12c2
Compare
What problem does this PR solve?
VMA enhancement data cannot be auto-collected by Agent or RVTools, leaving missing assessment data without a dedicated mechanism for users to provide it manually.
How was it solved?
Introduced
POSTandGET/api/v1/assessments/{id}/enhancement-dataendpoints to persist and retrieve user-provided VMA enhancement data.Summary by CodeRabbit
New Features
Bug Fixes
Tests