Zie619/n8n-workflows · error · HTTPException
Workflow not found in database
Error message
Workflow not found in database
What it means
A 404 from GET /api/workflows/{filename} raised when the filename passes validation and rate limiting but db.search_workflows(f'filename:"{filename}"', limit=1) returns no rows. The workflow lookup happens against the SQLite index, not the filesystem, so the DB has never heard of this file even if it exists on disk.
Source
Thrown at api_server.py:327
async def get_workflow_detail(filename: str, request: Request):
"""Get detailed workflow information including raw JSON."""
try:
# Security: Validate filename to prevent path traversal
if not validate_filename(filename):
print(f"Security: Blocked path traversal attempt for filename: {filename}")
raise HTTPException(status_code=400, detail="Invalid filename format")
# Security: Rate limiting
client_ip = request.client.host if request.client else "unknown"
if not check_rate_limit(client_ip):
raise HTTPException(
status_code=429, detail="Rate limit exceeded. Please try again later."
)
# Get workflow metadata from database
workflows, _ = db.search_workflows(f'filename:"{filename}"', limit=1)
if not workflows:
raise HTTPException(
status_code=404, detail="Workflow not found in database"
)
workflow_meta = workflows[0]
# Load raw JSON from file with security checks
workflows_path = Path("workflows").resolve()
# Find the file safely
matching_file = None
for subdir in workflows_path.iterdir():
if subdir.is_dir():
target_file = subdir / filename
if target_file.exists() and target_file.is_file():
# Verify the file is actually within workflows directory
try:
target_file.resolve().relative_to(workflows_path)
matching_file = target_fileView on GitHub (pinned to 94007c1445)
Solutions
- Trigger a reindex (POST /api/reindex with a valid ADMIN_TOKEN) so newly added files enter the database.
- Take the exact filename value from GET /api/workflows results instead of constructing it by hand.
- Verify the file lives inside a subdirectory of workflows/ — the indexer and filesystem search both expect that layout.
- If reindexing does not pick the file up, check the file is valid JSON and matches the indexer's inclusion rules.
Example fix
# before
workflows, _ = db.search_workflows(f'filename:"{filename}"', limit=1)
# after (parameterized exact-match lookup, quote-safe)
workflows, _ = db.search_workflows(f'filename:"{filename.replace(chr(34), "")}"', limit=1) Defensive patterns
Strategy: validation
Validate before calling
import urllib.request, json
def filename_in_index(base, name):
with urllib.request.urlopen(f'{base}/api/workflows?q={name}', timeout=5) as r:
items = json.load(r).get('workflows', [])
return any(w.get('filename') == name for w in items) Try / catch
try:
meta = client.get(f'/api/workflows/{name}').json()
except HTTPError as e:
if e.response.status_code == 404 and 'not found in database' in e.response.text:
client.post(f'/api/reindex?admin_token={TOKEN}') # then retry Prevention
- Reindex on every deploy that adds/removes workflow files.
- Use filenames exactly as the listing endpoint returns them.
- Treat a 404 'not found in database' as an index-staleness signal, not a user error.
When it happens
Trigger: Requesting a workflow JSON that was added to workflows/ after the last indexing run; a filename whose exact string (case, spacing, .json suffix) differs from the indexed value; the DB being rebuilt from a different directory snapshot; a filename containing a double quote breaking the quoted query.
Common situations: Git-pulling new workflow files without reindexing; renaming files on disk; querying with a name copied from the filesystem listing rather than from the API's own search results.
Related errors
- Error fetching stats: {str(e)}
- Error searching workflows: {str(e)}
- Workflow file '{filename}' not found on filesystem
- Workflow file '{filename}' not found
- Error fetching integrations: {str(e)}
AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15).
Data as JSON: /api/errors/b98f2493a6ef9167.
Report an issue: GitHub.