Skip to content

Fix CI build by generating TypeScript types from backend OpenAPI spec#2

Merged
cliff-de-tech merged 4 commits intomainfrom
copilot/fix-ci-workflow-type-errors
Jan 26, 2026
Merged

Fix CI build by generating TypeScript types from backend OpenAPI spec#2
cliff-de-tech merged 4 commits intomainfrom
copilot/fix-ci-workflow-type-errors

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Frontend build depends on auto-generated TypeScript types from backend's OpenAPI spec at shared/contracts/index.d.ts. These types are gitignored and require a running backend to generate, causing CI failures.

Changes

CI Workflow (frontend-build job)

  • Install Python deps and start backend server with test config
  • Poll /health endpoint until ready (max 60s)
  • Generate types via npm run generate:types
  • Build frontend
  • Cleanup backend process with if: always()

Type Definitions

  • Fix SchedulePostRequest type alias to use correct schema name routes__posts__ScheduleRequest (backend namespaces schemas by route)

ESLint Fix

  • Wrap loadConnectionStatus in useCallback to stabilize function identity and prevent exhaustive-deps warning
const loadConnectionStatus = useCallback(async () => {
  // ... fetch logic
}, [userId, getToken]);

useEffect(() => {
  loadConnectionStatus();
}, [isLoaded, userId, shouldRefresh, loadConnectionStatus]);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/Post-Bot/Post-Bot/web/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Problem

The CI workflow is failing with the following error:

Type error: Cannot find module '@shared/contracts/index' or its corresponding type declarations.
  > 19 | } from '@shared/contracts/index';

Root Cause:
The frontend build depends on auto-generated TypeScript types from the backend's OpenAPI spec at shared/contracts/index.d.ts. This file is:

  1. Gitignored (as it's auto-generated)
  2. Generated by scripts/generate-api-types.js which requires a running backend
  3. Not being generated in the CI workflow before the frontend build step

Error Location:

Solution

Modify .github/workflows/ci.yml to:

  1. Start the backend server in the background before the frontend build
  2. Wait for the backend to be ready
  3. Generate the TypeScript types from the OpenAPI spec
  4. Then proceed with the frontend build

The frontend-build job should be updated to:

  • Set up Python and install backend dependencies
  • Start the backend server in the background
  • Wait for the backend to be healthy (check /health or /openapi.json endpoint)
  • Generate types using npm run generate:types (which runs node scripts/generate-api-types.js)
  • Build the frontend

Additional Fix

There's also an ESLint warning in src/pages/settings.tsx line 124:

Warning: React Hook useEffect has a missing dependency: 'loadConnectionStatus'. Either include it or remove the dependency array.

This should be fixed by adding loadConnectionStatus to the useEffect dependency array.

Files to Modify

  1. .github/workflows/ci.yml - Update the frontend-build job
  2. web/src/pages/settings.tsx - Fix the useEffect dependency warning (if the file exists)

Expected Outcome

  • CI builds should pass successfully
  • Frontend can build with properly generated TypeScript types
  • No type errors or ESLint warnings

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 26, 2026 03:24
Co-authored-by: cliff-de-tech <137389025+cliff-de-tech@users.noreply.github.com>
Co-authored-by: cliff-de-tech <137389025+cliff-de-tech@users.noreply.github.com>
Co-authored-by: cliff-de-tech <137389025+cliff-de-tech@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI workflow to generate TypeScript types before frontend build Fix CI build by generating TypeScript types from backend OpenAPI spec Jan 26, 2026
Copilot AI requested a review from cliff-de-tech January 26, 2026 03:32
Copy link
Owner

@cliff-de-tech cliff-de-tech left a comment

Choose a reason for hiding this comment

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

LGTM

@cliff-de-tech cliff-de-tech marked this pull request as ready for review January 26, 2026 03:47
@cliff-de-tech cliff-de-tech merged commit 89cb2a1 into main Jan 26, 2026
4 of 5 checks passed
@cliff-de-tech cliff-de-tech deleted the copilot/fix-ci-workflow-type-errors branch January 26, 2026 04:03
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