Files
PaperClipAI/server
Huanyi Xie 8bff629465 fix(environments): skip blank lease ID queries (#15200)
## Thinking Path

> - Paperclip manages work for AI agents.
> - Runs can use environment leases.
> - A lease lookup sends its ID to a PostgreSQL UUID column.
> - An empty ID makes that query fail on every poll.
> - This pull request returns null before querying for blank IDs.
> - Valid lease IDs keep the existing lookup behavior.

## Linked Issues or Issue Description

Fixes: #15143

## What Changed

- Skip database access for empty or whitespace-only lease IDs.
- Cover empty, space, and newline IDs with a database-query spy.
- Keep an unknown valid UUID returning null. Existing lease tests cover
valid lookups.

## Verification

- The branch was rebased onto current master `252d9b50` to resolve the
test-file conflict.
- All 53 environment service tests passed on Node 24.19.0. The run used
cached dependencies and current database and shared-package source
aliases.
- The blank-ID cases assert that no database query occurs. The unknown
valid UUID still returns null. The existing suite covers stored leases.
- `git diff --check`: passed.
- A clean frozen install is blocked because upstream master adds two
OpenTelemetry packages without updating the lock file.
- Full typecheck and build were attempted on both unmodified master
`252d9b50` and this head in the same environment. Both fail with the
exact same runner `SessionRecord.cursor_prompt_usage` error (TS2339 at
`codex-runtime-adapter.ts:1572`). Full validation is pending CI on the
rebased commit.
- The earlier full test run had a Slack callback ordering failure that
also occurred on unmodified master.
- Greptile reviewed the previous head at 5/5 with no inline findings.

## Risks

Low risk. Only blank IDs return early. Non-blank IDs still use the
database. There is no schema or migration change.

## Model Used

OpenAI Codex, based on GPT-6, assisted with source review,
implementation and local test execution. The exact deployment model ID
and context-window size are not exposed in this session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change and contains no internal
Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass (targeted suite; full suite
pending above)
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes (no
user-facing configuration or command changes)
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green (new head checks are pending)
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-11-12 13:49:09 -06:00
..