Skip to content

CodexLens models route can return legacy text output and crash the models page #151

@ljh740

Description

@ljh740

Summary

The CodexLens models page can receive the wrong response shape from /api/codexlens/models, which causes the frontend to crash with:

TypeError: m.map is not a function

I reproduced this on:

  • Claude-Code-Workflow 7.3.8
  • codexlens-search v0.8.1

Reproduction

  1. Start the dashboard:
    ccw view
  2. Open the CodexLens page in the dashboard.
  3. The frontend expects /api/codexlens/models to return:
    {"success": true, "models": [ ... ]}
  4. In the failing case, the backend returns the legacy text output from codexlens-search list-models, so models is a string instead of an array.
  5. The React page then crashes because it does .map() on that value.

Expected

  • /api/codexlens/models should always return an array for models
  • /api/codexlens/models/download should propagate tool failures instead of wrapping them as success: true

Actual

Two related problems showed up:

  1. /api/codexlens/models can return legacy text output instead of JSON array data.
  2. /api/codexlens/models/download can return success: true even when the underlying tool output is:
    {"status":"failed","model":"..."}

Likely Cause

There appears to be a legacy CodexLens route implementation still active in ccw/dist/core/routes/codexlens-routes.js:

  • the models list handler calls spawnCli('codexlens-search', ['list-models']) instead of requesting JSON output
  • the download handler treats any zero exit code as success, even if the parsed JSON payload reports a failed download status

This causes a frontend/backend contract mismatch with the newer CodexLens page code, which expects a normalized array response.

Impact

  • /codexlens page can crash on load
  • download status can be falsely reported as success
  • debugging becomes confusing because the backend response shape is inconsistent

A minimal fix would be:

  • switch the models route to list-models --json
  • normalize the parsed response to an array
  • make the download route inspect the parsed JSON status instead of only checking the process exit code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions