Skip to content

fix(api): build prompt text in Python and drop pybars3 - #2096

Merged
phernandez merged 4 commits into
mainfrom
fix/2044-drop-pybars3
Nov 12, 2026
Merged

phernandez merged 4 commits into
mainfrom
fix/2044-drop-pybars3

Conversation

@phernandez

Copy link
Copy Markdown
Member

Stack 1/4: #2044 → #2078 → #2094 → #2000. Land bottom-up.

Why

pybars3 is unmaintained and carries CVE-2026-119716 (code injection when an attacker controls template source). Nix marks it insecure, so packagers need an exception to install Basic Memory. We used it only to render two fixed templates for /v2/projects/{id}/prompt/search and /prompt/continue-conversation.

What

  • New api/prompt_text.py builds both prompts in plain Python. The query and note text are inserted as values; nothing is ever compiled as a template.
  • Removed api/template_loader.py, templates/prompts/*.hbs, pybars3 and pymeta3 (uv.lock).
  • The endpoints and their response shape stay: nothing in Core or Cloud calls them now, but released clients may.
  • Dropped the router's catch-all that turned template errors into 500s, and the monkeypatched test for it. Plain functions have no template errors to catch.
  • test-int/read_cache/test_rendered_reads.py: one blank line from ruff format (the file on main is unformatted).

Closes #2044

Verification

  • just fast-check
  • just fast-test on the top of the stack (-m "not semantic and not benchmark"): 3993 passed, 21 skipped. Postgres runs in CI.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD

pybars3 is unmaintained and carries CVE-2026-119716 (code injection when
an attacker controls template source). Basic Memory only used it to render
two fixed prompt templates for the v2 prompt routes, so plain Python now
builds that text and inserts the query and note text as values. The
template loader, the .hbs files, pybars3 and pymeta3 are gone.

Closes #2044

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez marked this pull request as ready for review November 12, 2026 15:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T16:42:45.768247Z 4993a5c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

phernandez and others added 3 commits November 12, 2026 10:24
Signed-off-by: phernandez <paul@basicmachines.co>

# Conflicts:
#	pyproject.toml
#2104 dropped the scope list from the title check, and this test still
read it, so unit tests on main fail with KeyError: 'scopes'. That PR's CI
skipped the unit tests because it only touched a workflow file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv
Signed-off-by: phernandez <paul@basicmachines.co>
…x/2044-drop-pybars3

Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit 00d6859 into main Nov 12, 2026
41 of 42 checks passed
@phernandez
phernandez deleted the fix/2044-drop-pybars3 branch November 12, 2026 16:52
phernandez added a commit that referenced this pull request Nov 12, 2026
Stack 2/4, based on #2096.

## Why
`bm cloud sync-setup` compared the typed name exactly, while pull and
push match by permalink. A customer ran `sync-setup cesar` for a cloud
project named `Cesar`: setup failed, then `pull --name cesar` found the
cloud project, missed the local entry, and pointed back at the
sync-setup that had failed.

## What
- `_configured_project_name` finds a config entry by permalink.
Workspace resolution and `_require_local_sync_path` use it.
- `sync-setup` resolves the cloud project by permalink
(`_get_cloud_project`) and saves under the cloud spelling, or under an
existing entry's key so no duplicate entry is created. The local project
and the printed next steps use the same name.
- Tests drive the real `sync-setup` command through an injected httpx
client factory, without monkeypatch.

Closes #2078

## Verification
- `just fast-check`
- `just fast-test` on the top of the stack (`-m "not semantic and not
benchmark"`): 3993 passed, 21 skipped. Postgres runs in CI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD

---------

Signed-off-by: phernandez <paul@basicmachines.co>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unmaintained pybars3 dependency affected by CVE-2026-119716

1 participant