Skip to content

Fix k8s-pods blank render and document scaffold pitfalls - #11

Merged
setnilson merged 2 commits into
masterfrom
k8s-pods-app-jvJwHl
Sep 30, 2026
Merged

setnilson merged 2 commits into
masterfrom
k8s-pods-app-jvJwHl

Conversation

@setnilson

Copy link
Copy Markdown
Owner

Summary

Fixes the blank render of the k8s-pods app and documents the scaffolding pitfalls that caused it, so the next generated app avoids them.

Root causes found:

  • npm resolves the ^18 || ^19 peer range of @datadog/apps-frontend to a nested react@19.3.0 copy for the app (npm does not apply plain root overrides to peer resolutions), producing two React instances in the bundle. The app crashed on mount with Cannot read properties of null (reading 'useEffect') / ReactCurrentDispatcher errors and rendered blank.
  • An empty-string DD_SITE/DATADOG_SITE env value is rejected by the Datadog Vite plugin itself, breaking dev/build in environments where the variable is set but empty.
  • The generated package.json scripts call npx datadog-apps …, a CLI that does not resolve in this workspace.

Per the follow-up request, the app now runs on mock data for demo purposes (verified working in a browser: table, namespace filter, delete action).

Changes

  • apps/k8s-pods/src/App.tsx: replaced the backend-driven listing with a mock pod list (demo); delete now removes the pod locally. Backend files listPods.backend.ts / deletePod.backend.ts removed since unused; @tanstack/react-query dropped from the app's dependencies.
  • Root package.json: added a scoped override (@datadog/apps-frontend → react/react-dom: $react) so the peer resolves to the single workspace React 18.3.1; regenerated lockfile no longer contains a nested apps/k8s-pods/node_modules/react copy.
  • apps/k8s-pods/vite.config.ts: resolve.dedupe for react/react-dom and a guard that unsets empty-string DATADOG_SITE/DD_SITE env values before plugin construction; also added the root-manifest site fallback matching the other apps.
  • docs/agents/scaffolding.md (new): documented all scaffold pitfalls with fixes — unresolvable datadog-apps CLI scripts, React version alignment with root overrides, the npm peer-driven React duplication and its override + dedupe fix, and the empty DD_SITE guard. Linked from the root AGENTS.md "Adding another app" section.
  • Lockfile gate re-run against latest origin/master.

Testing

  • Browser-verified with Playwright against npm run dev: the app renders the pods table with mock data, the namespace filter works, and Delete removes an unhealthy pod with a confirmation message (screenshot attached). Console shows only benign DRUIDS strict-mode warnings after the fix; the React duplicate-instance errors are gone.
  • npm run typecheck -w apps/k8s-pods and npm run lint -w apps/k8s-pods pass with zero warnings.
  • npm run build -w apps/k8s-pods passes (with DD_SITE unset; the new env guard also handles the empty-string case in-process).
  • Lockfile gate: fetched/merged latest origin/master, regenerated package-lock.json (npm install --package-lock-only --ignore-scripts), validated with npm ci --ignore-scripts; confirmed the apps/k8s-pods workspace records exist and no nested apps/k8s-pods/node_modules/react entry remains.

PR by Bits - View session in Datadog

Co-authored-by: setnilson <110850377+setnilson@users.noreply.github.com>
Co-authored-by: setnilson <110850377+setnilson@users.noreply.github.com>
@datadog-staging

datadog-staging Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

View session in Datadog

Bits Code status: ✅ Done

Comment @datadog-staging to request changes

@setnilson
setnilson merged commit 81d5052 into master Sep 30, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants