Added isLoadTested and grafana link field to the promote request API#282
Added isLoadTested and grafana link field to the promote request API#282shubhangi-raj-meesho wants to merge 2 commits intodevelopfrom
Conversation
535de47 to
5b555c6
Compare
| // Validate load test fields for promote requests | ||
| if requestType == PromoteRequestType && payloadObject.IsLoadTested { | ||
| if err := validateGrafanaLink(payloadObject.GrafanaLink); err != nil { | ||
| return constant.EmptyString, http.StatusBadRequest, err | ||
| } | ||
| } |
There was a problem hiding this comment.
No need to validate the grafana link, just check if empty. It will be shown on UI and will be checked there. And there can be cases where it is not a grafana link but is a different page for showing load test results.
Lets keep it generic, keep the name LoadTestResultsLink, json:load_test_results_link
There was a problem hiding this comment.
Resolved.
…ana link validation function
WalkthroughExtends the Payload struct with two new fields to track load testing status and results, and adds validation logic in the promote request handler to ensure that when load testing is flagged as completed, a valid results link is provided. Changes
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
horizon/internal/predator/handler/predator.go (1)
175-180: Validation logic is correct; consider adding URL format validation.The guard correctly ensures
LoadTestResultsLinkis required whenIsLoadTestedis true for promote requests. The placement after unmarshalling and before model name derivation is appropriate.Consider validating that
LoadTestResultsLinkis a well-formed URL (e.g., starts withhttp://orhttps://) to prevent garbage data from being stored and displayed to admins during review.💡 Optional: Add basic URL validation
// Validate load test fields for promote requests if requestType == PromoteRequestType && payloadObject.IsLoadTested { if payloadObject.LoadTestResultsLink == constant.EmptyString { return constant.EmptyString, http.StatusBadRequest, errors.New("load test results link is required when load tested is true for the model requested") } + if !strings.HasPrefix(payloadObject.LoadTestResultsLink, "http://") && !strings.HasPrefix(payloadObject.LoadTestResultsLink, "https://") { + return constant.EmptyString, http.StatusBadRequest, errors.New("load test results link must be a valid URL starting with http:// or https://") + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@horizon/internal/predator/handler/predator.go` around lines 175 - 180, Add basic URL format validation for LoadTestResultsLink when handling PromoteRequestType: after the existing check that payloadObject.IsLoadTested is true and payloadObject.LoadTestResultsLink is non-empty, validate that payloadObject.LoadTestResultsLink is a well-formed URL (e.g., begins with "http://" or "https://", or use net/url.Parse and ensure Scheme is http/https and Host is non-empty). If validation fails, return a Bad Request with a clear error message. Update the block referencing PromoteRequestType, payloadObject.IsLoadTested, and payloadObject.LoadTestResultsLink to include this validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@horizon/internal/predator/handler/predator.go`:
- Around line 175-180: Add basic URL format validation for LoadTestResultsLink
when handling PromoteRequestType: after the existing check that
payloadObject.IsLoadTested is true and payloadObject.LoadTestResultsLink is
non-empty, validate that payloadObject.LoadTestResultsLink is a well-formed URL
(e.g., begins with "http://" or "https://", or use net/url.Parse and ensure
Scheme is http/https and Host is non-empty). If validation fails, return a Bad
Request with a clear error message. Update the block referencing
PromoteRequestType, payloadObject.IsLoadTested, and
payloadObject.LoadTestResultsLink to include this validation.
📌 Summary
Added an
isLoadTestedfield to the promote request API. When a user submits a request to promote a model from the INT environment to PROD, they can indicate whether the model has been load tested. If marked as load tested, the correspondingGrafana linkmust be provided. This link will be visible to the admin while reviewing the model promotion request. Updated the relevant structs to support this change.Testing
Tested on the custodian setup confirms that the additional fields do not impact other API endpoints and are working as expected.
📂 Modules Affected
horizon(Real-time systems / networking)online-feature-store(Feature serving infra)trufflebox-ui(Admin panel / UI)infra(Docker, CI/CD, GCP/AWS setup)docs(Documentation updates)___________✅ Type of Change
___________Summary by CodeRabbit
Release Notes