Skip to content

Clear code-quality warnings; make application-view e2e assertions real#5634

Merged
norman-abramovitz merged 7 commits into
cloudfoundry:developfrom
nabramovitz:fix/code-quality-warnings
Jul 12, 2026
Merged

Clear code-quality warnings; make application-view e2e assertions real#5634
norman-abramovitz merged 7 commits into
cloudfoundry:developfrom
nabramovitz:fix/code-quality-warnings

Conversation

@nabramovitz

@nabramovitz nabramovitz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Clears all 46 open warning-severity findings on the Code Quality board (the level that holds both dimensions at "Fair"), fixing the real bugs behind them rather than suppressing.

Backend (30 findings)

Every Go warning was a genuinely dropped error:

  • initSessionStore dereferenced the store returned by all three session-store constructors before checking err — a constructor failure was a nil-deref panic at startup.
  • The helm job restWorker read response.StatusCode before the err check. DoProxySingleRequest always returns a nil response with a non-nil error, and the worker runs in its own goroutine, so this was a whole-process crash. Errored jobs now carry an Err marker; UpdatePods skips its stale-pod sweep and UpdateResources keeps the cached resource when a job failed, so a transient proxy error no longer empties the release view.
  • The kube terminal ignored the getClients error (nil-client panic at secretClient.Create) and assigned its pod-wait timeout error to a loop-shadowed variable, reporting a never-started pod as success.
  • Three kubeconfig auth providers (azure, kubeconfig, oidc) dropped the ParseKubeConfig error, so a malformed kubeconfig upload panicked jetstream; awsiam dropped the getTokenIAM error and persisted an empty token as success.
  • unarchive dropped the write-side Close error (lost-data class); the cfapppush no-op init method is deleted; the dashboard tryDecode* error discards are now explicit.

Frontend (16 findings)

  • SetPage's constructor assigned the keepPages parameter instead of the parameter property, so forceLocalPage never actually forced keepPages on the dispatched action.
  • Smaller items: uninitialized-then-always-overwritten local in the firehose formatter, two missing spaces in concatenated user-facing strings, a duplicated property in the proxy config template, and a collapsed null/undefined comparison.

E2E: real assertions instead of hollow ones

Ten application-view tests asserted expect(boolExists !== undefined) — always true for a boolean, so they verified nothing. Each now either asserts real behavior or skips with the reason it can't be tested here:

  • Services unbind / details: seed a user-provided service instance and binding through the CF API, then assert the bound instance's card and its Unbind row action. New createUserProvidedService / deleteServiceInstance helpers (labeled stratos-e2e-test and covered by the cleanup sweep, which now reaps service instances before spaces).
  • Variables edit / delete: seed a variable, assert the Edit/Delete row actions behind the signal-list kebab.
  • Events filtering: assert the signal-list name-filter input.
  • SSH / per-instance logs: skipped — they need a running instance and the API-created test app has no bits.
  • Log auto-scroll / level filter / download: skipped — the modern log viewer auto-scrolls by default and has no filter or download UI (these two features were not carried over from the Material UI; worth separate issues if they should return).

Giving these tests teeth exposed two latent harness bugs the hollow assertions had been hiding: updateAppEnvironment used POST where CF API v3 requires PATCH, and openRowActionMenuByRow returned a menu bound to the removed Material menu selector instead of the row's own actions menu. bindService now returns the binding guid (guarded for managed bindings, which return 202 with an empty body).

Verification

  • make lint: golangci-lint 0 issues on both Go modules; make check gate green (eslint, 3094 frontend tests, production build, go tests).
  • The five rewritten e2e tests pass and five skip at 2 workers against a live local stack; the remaining application-view failures predate this change (stale pre-modernization selectors, tracked separately).

Shared-URL banner correctness (found during live verification)

Live-verifying this branch against a dev instance with 4 CF + 4 Kubernetes shared-URL endpoints surfaced a mislabelled banner: the home page fed every connected endpoint into the duplicate-URL counter and reported "8 Cloud Foundry endpoints share a URL" when only 4 CF endpoints exist. Duplicate detection now runs per endpoint type, and both banners (home and the Application Wall / Marketplace / Services one) build their sentence from a single shared helper so the phrasing cannot drift: "4 Cloud Foundry endpoints share a URL." / "4 Cloud Foundry endpoints and 4 Kubernetes endpoints share URLs." The wall banner's page-specific explanation moves to its own line. Included here rather than as a follow-up so operators picking up this fix level get the banner correction with it.

Endpoint management kebab on the CF picker + Reconnect

Also from live verification: the /cloud-foundry picker is a projection of the Endpoints page onto its CF subset, but its cards had no management menu. The per-endpoint kebab moves into a shared EndpointRowActionsService used by both surfaces (the picker omits Unregister — registration changes are admin-level and stay on the Endpoints page), and gains a Reconnect action for connected endpoints: re-auth in place through the connect dialog, prefilled with the live connection's username. Two connect-dialog fixes make that flow safe — the success detector no longer treats a pre-existing connection as an instant success (gated on hasAttemptedConnect, matching the error path), and the username prefill prefers the live connection's user over the localStorage history.

…ssion store

Code scanning flagged 30 warning-severity findings across the backend;
each was a real dropped error, not noise:

- initSessionStore dereferenced the store returned by all three session
  store constructors before checking err (nil-deref panic at startup on
  constructor failure)
- helm job restWorker logged response.StatusCode before the err check
  (nil-deref panics the worker; errored jobs now send a zero result so
  the collector still gets one result per job)
- kube terminal createPod ignored the getClients error (nil client
  panic) and assigned its pod-wait timeout error to a loop-shadowed
  variable, so a never-started pod was reported as success
- azure/kubeconfig/oidc auth dropped the ParseKubeConfig error (a
  malformed kubeconfig upload panics jetstream); awsiam dropped the
  getTokenIAM error and persisted an empty token as success
- unarchive dropped the write-side Close error (lost-data class)
- dashboard tryDecode* err discards are now explicit; cfapppush's no-op
  init method is gone
The constructor body assigned the parameter, not the parameter
property, so forceLocalPage has never forced keepPages on the action
object reducers read. Flagged by code scanning as a useless
assignment.
- firehose formatter: declare 'filtered' without an initializer; every
  switch arm and the catch assign it
- seo.data / kubedash confirmation: missing space in concatenated
  user-facing strings
- json-schema-generator: collapse the null/undefined pair to a loose
  null check
- proxy.conf.template: drop the duplicated ws property
Ten tests asserted 'expect(boolExists !== undefined)' - always true for
a boolean, so they verified nothing (flagged by code scanning as
comparisons between incompatible types). Each now either asserts real
behavior or skips with the reason the behavior is untestable here:

- services unbind/details: seed a user-provided service instance and a
  binding via the CF API, then assert the bound instance's card and its
  Unbind row action (new createUserProvidedService/deleteServiceInstance
  helpers; bindService now returns the binding guid for cleanup)
- variables edit/delete: seed a variable, assert the Edit/Delete row
  actions behind the signal-list kebab
- events filtering: assert the signal-list name filter input
- SSH / per-instance logs: skipped - they need a running instance and
  the API-created test app has no bits
- log auto-scroll / level filter / download: skipped - the modern log
  viewer auto-scrolls by default and has no filter or download UI

Also fixes two latent harness bugs the hollow assertions were hiding:
updateAppEnvironment used POST where CF API v3 requires PATCH, and
openRowActionMenuByRow returned a menu bound to the dead Material menu
selector instead of the row's own actions menu.

Verified: 5 pass + 5 skip at 2 workers; remaining application-view
failures predate this change (stale pre-modernization selectors).
The home banner fed every connected endpoint into the duplicate-URL
counter but labelled the result 'Cloud Foundry endpoints' - with 4 CF
and 4 k8s endpoints sharing URLs it claimed '8 Cloud Foundry endpoints
share a URL'. Duplicate detection is only meaningful within a type, so
the count now runs per cnsi_type.

Both banners (home page and the CF Application Wall / Marketplace /
Services one) now build the sentence from one shared helper so the
phrasing cannot drift: per-type counts joined into a single sentence
with type labels from the entity catalog, and the verb agreeing with
how many distinct URLs are shared - '4 Cloud Foundry endpoints share a
URL.' vs '4 Cloud Foundry endpoints and 4 Kubernetes endpoints share
URLs.'

The CF banner's page-specific explanation moves to its own line and
'view a single endpoint' becomes 'narrow to a single endpoint' (the
filter narrows the entity list; it doesn't open an endpoint).

Live-verified against a dev instance with 4 CF + 4 k8s shared-URL
endpoints connected.
The /cloud-foundry picker is a projection of the Endpoints page onto its
CF subset, but its cards carried no management actions. The per-endpoint
kebab (Connect / Disconnect / Edit / Unregister) moves out of the
endpoints signal list into a shared EndpointRowActionsService consumed
by both surfaces, so the menus cannot drift. The picker passes
unregister:false - registering and unregistering are admin-level
operations on the global registration and stay on the Endpoints page.

Adds the long-discussed Reconnect action for connected endpoints:
re-auth in place via the connect dialog, no manual disconnect step -
the same flow the stale-token snackbar uses. Two dialog fixes make
that flow safe:

- the connect success detector derived 'connected' from endpoint.user
  being set, which is true from the moment the dialog opens against an
  already-connected endpoint - after the 1s connect delay the dialog
  self-closed with a false 'Connected' snackbar. Success is now gated
  on hasAttemptedConnect, the same guard the error path already used.
- the username prefill only knew the localStorage history of past
  connects; the dialog config now carries the live connection's user,
  preferred over the remembered value, so Reconnect opens prefilled.

Live-verified: reconnect round-trip against a dev instance replaces
the token with the dialog staying open until submit.

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@norman-abramovitz norman-abramovitz merged commit 4c4c092 into cloudfoundry:develop Jul 12, 2026
21 checks passed
@nabramovitz nabramovitz deleted the fix/code-quality-warnings branch July 12, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants