Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions jina_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ def search_bibtex(
) -> list[dict]:
"""Search for BibTeX entries via DBLP and Semantic Scholar."""

errors: list[str] = [] # record source failures so an outage is not silently "no matches"

def _search_dblp() -> list[dict]:
q = f"{query} {author}" if author else query
params = {"q": q, "format": "json", "h": str(min(num * 2, 100))}
Expand Down Expand Up @@ -693,7 +695,8 @@ def _search_dblp() -> list[dict]:
}
)
return results
except Exception:
except Exception as e:
errors.append(f"DBLP: {e}")
return []

def _search_semantic_scholar() -> list[dict]:
Expand Down Expand Up @@ -730,7 +733,8 @@ def _search_semantic_scholar() -> list[dict]:
}
)
return results
except Exception:
except Exception as e:
errors.append(f"Semantic Scholar: {e}")
return []

# Run both in sequence (could be threaded but keep simple)
Expand Down Expand Up @@ -761,6 +765,12 @@ def _search_semantic_scholar() -> list[dict]:

results = list(seen_titles.values())[:num]

# A lookup that errored must not masquerade as "no matches": if every source we tried failed
# and we got nothing, surface the failure (the CLI maps it to a clear error + exit code)
# instead of returning an empty list.
if not results and errors:
raise RuntimeError("bibtex lookup failed (" + "; ".join(errors) + ")")

# Generate BibTeX
for r in results:
r["bibtex"] = _make_bibtex(r)
Expand Down
Loading