Skip to content

fix(ci): resolve backend lint F821 and stale frontend test mocks#629

Merged
utksh1 merged 2 commits into
utksh1:mainfrom
anshul23102:fix/ci-regressions-db-undefined-and-stale-test-mocks
Jun 7, 2026
Merged

fix(ci): resolve backend lint F821 and stale frontend test mocks#629
utksh1 merged 2 commits into
utksh1:mainfrom
anshul23102:fix/ci-regressions-db-undefined-and-stale-test-mocks

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

Summary

Fixes two CI regressions introduced by commits 0e03877 and a2a7e02 that are currently blocking all open PRs (backend-lint and frontend-checks failures).

Root Causes

1. Backend lint failure — F821 Undefined name 'db' (backend/secuscan/workflows.py:82)

Commit 0e03877 added a get_target_policy(db, ...) call inside WorkflowScheduler._run_workflow(), but db was never acquired in that method. The tick() method correctly obtains db = await get_db() but does not pass it to _run_workflow().

Fix: Added db = await get_db() at the top of _run_workflow().

# Before
async def _run_workflow(self, workflow_id: str, steps: List[Dict[str, Any]]):
    logger.info(...)
    for step in steps:
        ...
        target_policy = await get_target_policy(db, ...)  # NameError: db undefined

# After
async def _run_workflow(self, workflow_id: str, steps: List[Dict[str, Any]]):
    logger.info(...)
    db = await get_db()  # acquire database connection
    for step in steps:
        ...
        target_policy = await get_target_policy(db, ...)  # now resolved

2. Frontend test failures — stale mocks after ToolConfig.tsx and Workflows.tsx updates

Commit a2a7e02 updated ToolConfig.tsx to call three new API functions in a Promise.all:

const [s, policies, credentials, sessions] = await Promise.all([
  getSettings(),
  listTargetPolicies(),   // new
  listCredentialProfiles(), // new
  listSessionProfiles(),  // new
])

Tests that only mocked the original API functions had these three return undefined, causing Promise.all to resolve with a rejected upstream, which prevented setServerLimits from running and broke max/min attribute assertions in ToolConfigTimeout.test.tsx.

The same commit also updated startTask to accept a 5th executionContext argument, breaking the startTask call assertion in ToolConfigDynamic.test.tsx.

Workflows.tsx changed emptySteps to include execution_context in each step object, making the createWorkflow assertion in Workflows.test.tsx fail with a shape mismatch.

Fixes applied:

File Change
ToolConfigDynamic.test.tsx Added listTargetPolicies, listCredentialProfiles, listSessionProfiles, getSettings to vi.mock factory and beforeEach mock returns; updated startTask assertion to accept 5th executionContext argument
ToolConfigTimeout.test.tsx Added three new API functions to vi.mock factory and beforeEach so Promise.all resolves correctly
Workflows.test.tsx Updated createWorkflow expectation to include execution_context in the steps array

Verification

  • ruff check backend/secuscan/workflows.py passes with no errors
  • All three frontend test assertions align with the current component behavior

Impact

This unblocks all currently open PRs that are failing backend-lint and frontend-checks due to these pre-existing regressions.

Two separate CI regressions were introduced by commits 0e03877 and a2a7e02:

Backend lint (F821 - Undefined name 'db')
  workflows.py._run_workflow() calls get_target_policy(db, ...) but 'db'
  was never acquired in that method. tick() obtains 'db' but does not
  pass it into _run_workflow(). Fixed by adding db = await get_db() at
  the top of _run_workflow().

Frontend unit test failures (3 tests)
  ToolConfig.tsx now calls listTargetPolicies(), listCredentialProfiles(),
  and listSessionProfiles() inside its useEffect via Promise.all. Tests
  that only mocked the original 3-4 API functions caused Promise.all to
  reject (unmocked vi.fn() returns undefined, not a Promise), making
  setServerLimits never execute and breaking max/min attribute assertions.

  Workflows.tsx changed emptySteps to include an execution_context object
  in each step. The createWorkflow assertion expected the old shape.

Fixes applied:
  - ToolConfigDynamic.test.tsx: add listTargetPolicies, listCredentialProfiles,
    listSessionProfiles, getSettings to vi.mock factory and beforeEach mocks;
    update startTask assertion to accept the new 5th executionContext argument
  - ToolConfigTimeout.test.tsx: add the three new API functions to vi.mock
    factory and beforeEach mocks so Promise.all resolves correctly
  - Workflows.test.tsx: update createWorkflow expectation to include
    execution_context in the steps array
…mpliance

{ items: [] } was inferred as { items: never[] }, which does not satisfy
NamedResourceList<T> (requires items: T[] and total: number). Added total: 0
to all three mock returns so TypeScript accepts the fixture without casting.
@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label area:ci CI, tooling, or automation work area:backend Backend API, database, or service work area:frontend Frontend React/UI work labels Jun 7, 2026
Copy link
Copy Markdown
Owner

@utksh1 utksh1 left a comment

Choose a reason for hiding this comment

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

Focused CI baseline repair with the missing backend db acquisition and updated frontend mocks/resource-list fixtures. Checks are green; approving for merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work area:ci CI, tooling, or automation work area:frontend Frontend React/UI work gssoc:approved Admin validation: approved for GSSoC scoring level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants