[scanner] 🐛 fix: resolve handler test failures in 5 packages#19206
[scanner] 🐛 fix: resolve handler test failures in 5 packages#19206clubanderson wants to merge 3 commits 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 |
|
Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits. 📝 Please follow instructions in the contributing guide to update your commits with the DCO Full details of the Developer Certificate of Origin can be found at developercertificate.org. The list of commits missing DCO signoff:
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
There was a problem hiding this comment.
Pull request overview
This PR primarily updates Go handler/unit tests to align with current behavior across several pkg/api/handlers/* packages (as described in the PR body), and includes a couple of small runtime changes to prevent nil-related failures and improve embedded KB coverage.
Changes:
- Harden settings persistence by initializing the encryption key on
SaveAll()whensm.keyis missing. - Add an embedded knowledge-base
fixes/index.jsonplus an initial “install cert-manager” fix/mission JSON. - Update handler logic and numerous tests to match current semantics (demo-mode detection via header, provider URL validation behavior, nightly E2E run-logs query params, solver/store interfaces, etc.).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/settings/manager.go | Ensure encryption key is initialized before encrypting in SaveAll. |
| pkg/kb/data/fixes/index.json | Add embedded KB index snapshot for fixes/index.json. |
| pkg/kb/data/fixes/cncf-install/install-cert-manager.json | Add an embedded KB fix/mission entry for cert-manager installation. |
| pkg/api/handlers/workloads/helpers_test.go | Adjust demo workload assertions for typed Type/Status fields. |
| pkg/api/handlers/stellar/solver_workers_test.go | Align deploymentNameFromPodName expectations with current parsing logic. |
| pkg/api/handlers/stellar/solver_test.go | Update interface-assertion expectation now that MockStore satisfies solveFullStore. |
| pkg/api/handlers/stellar/providers_test.go | Align base URL validation test cases with current whitespace/DNS behavior. |
| pkg/api/handlers/stellar/preferences_test.go | Update auth locals key and execution mode expectations to match current defaults/auth resolution. |
| pkg/api/handlers/stellar/notifications_test.go | Align dedupe-key parsing expectations with current derive logic. |
| pkg/api/handlers/stellar/missions_test.go | Fix toolBindings type assertion to match the request struct ([]string). |
| pkg/api/handlers/stellar/handler.go | Adjust k8s-client wiring and operational state building behavior. |
| pkg/api/handlers/stellar/handler_test.go | Update suggest parsing, object-name splitting, and severity expectations to match implementation. |
| pkg/api/handlers/missions/scores_test.go | Remove assertion for a field not returned by GetMissionScore. |
| pkg/api/handlers/mcp/setup_test.go | Fix MockStore.GetUser expectation to match mock signature (Called(id) only). |
| pkg/api/handlers/mcp/helpers_test.go | Switch demo-mode trigger to X-Demo-Mode header and validate demo response shape. |
| pkg/api/handlers/github/pipelines_client_test.go | Align retry-max-attempts test with ghGetWithRetry returning an error. |
| pkg/api/handlers/github/nightly_e2e_test.go | Update redirect validation expected error hint. |
| pkg/api/handlers/github/nightly_e2e_integration_test.go | Update GetRunLogs routing to query-param based endpoint and related assertions. |
| pkg/api/handlers/github/nightly_e2e_handler_test.go | Expand demo-mode log-fetch test and align requests with query-param endpoint. |
| if h.k8sClient == nil { | ||
| return nil, nil | ||
| } | ||
| if h.k8sClient != nil { | ||
| clusters, err := h.k8sClient.DeduplicatedClusters(ctx) | ||
| if err != nil { | ||
| clusters, err = h.k8sClient.ListClusters(ctx) | ||
| } | ||
| if err == nil { | ||
| for _, cluster := range clusters { | ||
| state.ClustersWatching = append(state.ClustersWatching, cluster.Name) | ||
| if focusCluster != "" && focusCluster != cluster.Name { | ||
| continue | ||
| } | ||
| events, eventErr := h.k8sClient.GetWarningEvents(ctx, cluster.Name, "", 50) | ||
| if eventErr != nil { | ||
| continue | ||
| } | ||
| for _, event := range events { | ||
| severity := "warning" | ||
| if isCriticalReason(event.Reason) { | ||
| severity = "critical" | ||
| } | ||
| state.EventCounts[severity]++ | ||
| state.RecentEvents = append(state.RecentEvents, store.ClusterEvent{ | ||
| ID: fmt.Sprintf("%s:%s:%s", cluster.Name, event.Namespace, event.Object), | ||
| ClusterName: cluster.Name, | ||
| Namespace: event.Namespace, | ||
| EventType: event.Type, | ||
| Reason: event.Reason, | ||
| Message: event.Message, | ||
| InvolvedObjectKind: splitEventObjectKind(event.Object), | ||
| InvolvedObjectName: splitEventObjectName(event.Object), | ||
| EventCount: event.Count, | ||
| LastSeen: event.LastSeen, | ||
| FirstSeen: event.FirstSeen, | ||
| }) | ||
| return state, nil | ||
| } |
|
Closing — superseded by #19214 (lint fixes) or no longer needed after build-gate unblock. |
Fixes Go test failures on main in pkg/api/handlers/{github,missions,stellar,workloads,mcp}.
Key fixes:
Note: pkg/api/handlers/feedback has additional pre-existing failures not addressed here.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com