lfnovo/open-notebook · warning · HTTPException

{str(e)}

Error message

{str(e)}

What it means

400 that transparently re-wraps an InvalidInputError from the search layer, passing its message through as the HTTP detail. It means the search request itself was malformed (e.g. empty/invalid query or bad search parameters).

Source

Thrown at api/routers/search.py:56

                minimum_score=search_request.minimum_score,
            )
        else:
            # Text search
            results = await text_search(
                keyword=search_request.query,
                results=search_request.limit,
                source=search_request.search_sources,
                note=search_request.search_notes,
            )

        return SearchResponse(
            results=results or [],
            total_count=len(results) if results else 0,
            search_type=search_request.type,
        )

    except InvalidInputError as e:
        raise HTTPException(status_code=400, detail=str(e))
    except DatabaseOperationError as e:
        logger.error(f"Database error during search: {str(e)}")
        raise HTTPException(status_code=500, detail=f"Search failed: {str(e)}")
    except HTTPException:
        raise
    except OpenNotebookError:
        raise
    except Exception as e:
        logger.error(f"Unexpected error during search: {str(e)}")
        raise HTTPException(status_code=500, detail=f"Search failed: {str(e)}")


async def stream_ask_response(
    question: str, strategy_model: Model, answer_model: Model, final_answer_model: Model
) -> AsyncGenerator[str, None]:
    """Stream the ask response as Server-Sent Events."""
    try:
        final_answer = None

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Ensure the query field is non-empty and trimmed
  2. Send a supported type ('text' or 'vector')
  3. Check the error detail — it contains the original InvalidInputError message
Defensive patterns

Strategy: validation

Validate before calling

const q = query.trim();
if (!q) throw new Error('Query required');
if (!['text','vector'].includes(type)) throw new Error('Bad type');

Try / catch

catch (e) { if (e.status === 400) showUserMessage(e.detail); }

Prevention

When it happens

Trigger: POST /api/search where the query string is empty, too long, or the search type/query combination fails validation inside vector_search/full_text_search.

Common situations: Frontend sending an empty query box value, whitespace-only queries, unsupported search type string reaching the service layer.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/24ca020706b29842. Report an issue: GitHub.