Fix/env resolution (#6)#7
Conversation
* Update pip version badge (#5) * use cwd based dotenv instead of caller-file based * update change log
* fix chunking to hard-splot text that exceeds page size * Surface actionable embedding errors across CLI commands * supress false .env conflict warning * updated docs and changelog
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| from xtrace_sdk.cli.commands._utils._disk_loader import _SUPPORTED | ||
| supported = ", ".join(sorted(_SUPPORTED)) | ||
| console.print(f"[yellow]No readable files found. Supported types: {supported}[/]") | ||
| console.print("[dim]Hint: for advanced ingestion workflows, use the Python SDK directly.[/]") |
There was a problem hiding this comment.
Hint prints non-JSON text when --json is active
Medium Severity
When matched_files == 0 and json_out=True, _json_error() outputs JSON and returns (it does not raise), then line 243's console.print unconditionally prints a non-JSON hint message. This corrupts the JSON output stream for machine consumers using --json. The hint line sits at the same indentation as the if json_out / elif / else chain, so it executes for all branches including the JSON path.
|
|
||
| - CLI commands failed to locate `.env` when installed from PyPI (`pip install xtrace-ai-sdk`). `dotenv.load_dotenv()` without arguments searches from the caller's file directory (site-packages), never reaching the user's working directory. All 13 call sites now use `find_dotenv(usecwd=True)` for cwd-based discovery. Editable installs (`pip install -e .`) were unaffected because the source tree sits under the user's home directory. | ||
| - `_chunk_into_pages` emitted oversized chunks when a single sentence exceeded `page_size`. These are now hard-split by character boundary. `_chunk_json` gains a `cap_json_elements` option to further split array elements that exceed the page size. | ||
| - `init` no longer warns about `.env` key conflicts when the existing value already matches the value being written. T |
There was a problem hiding this comment.
CHANGELOG entry has truncated sentence ending in "T"
Low Severity
The third bullet under "Fixed" ends with a dangling . T — clearly a truncated or partially deleted sentence that was accidentally committed. This is user-facing documentation in the CHANGELOG.md and will look broken to anyone reading the release notes.
|
|
||
| async def _embed_all() -> list[Any]: | ||
| if max_parallel_embeddings is not None: | ||
| sem = asyncio.Semaphore(max_parallel_embeddings) |
There was a problem hiding this comment.
Zero parallel embeddings causes silent infinite hang
Medium Severity
Passing --max-parallel-embeddings 0 creates asyncio.Semaphore(0), which starts with zero permits. Every call to async with sem: blocks forever since no task can ever acquire the semaphore and nothing calls release(). The CLI silently hangs with no error message. There is no validation that this value is positive before it reaches Semaphore().


Update pip version badge (Update pip version badge #5)
use cwd based dotenv instead of caller-file based
update change log
Note
Medium Risk
Touches multiple CLI entrypoints and chunking/embedding error handling; behavior changes could affect ingestion/query results and concurrency under load, but scope is limited to CLI and embedding provider error surfaces.
Overview
Fixes CLI
.envdiscovery when installed from PyPI by switching alldotenv.load_dotenv()call sites tofind_dotenv(usecwd=True).Improves ingestion robustness: text chunking now hard-splits single overlong sentences, JSON chunking can optionally cap/split oversized array elements, and
xtrace xvec load/upsert-fileadd--max-chunk-charsplus--max-parallel-embeddingsto control chunk size and embedding concurrency.Adds
EmbeddingError(with HTTPstatusandchunk_len) and updates the Ollama embedding provider plus embedding CLI commands (load,upsert,upsert-file,retrieve) to catch it and print targeted hints; also tightensinitenv conflict warnings and adjusts release workflow versioning to only setSETUPTOOLS_SCM_PRETEND_VERSIONon exact tag builds.Written by Cursor Bugbot for commit eb96aa1. This will update automatically on new commits. Configure here.