Skip to content

Fix/env resolution (#6)#7

Merged
liwenXtrace merged 3 commits into
mainfrom
staging
Apr 1, 2026
Merged

Fix/env resolution (#6)#7
liwenXtrace merged 3 commits into
mainfrom
staging

Conversation

@liwenXtrace

@liwenXtrace liwenXtrace commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

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 .env discovery when installed from PyPI by switching all dotenv.load_dotenv() call sites to find_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-file add --max-chunk-chars plus --max-parallel-embeddings to control chunk size and embedding concurrency.

Adds EmbeddingError (with HTTP status and chunk_len) and updates the Ollama embedding provider plus embedding CLI commands (load, upsert, upsert-file, retrieve) to catch it and print targeted hints; also tightens init env conflict warnings and adjusts release workflow versioning to only set SETUPTOOLS_SCM_PRETEND_VERSION on exact tag builds.

Written by Cursor Bugbot for commit eb96aa1. This will update automatically on new commits. Configure here.

sgonz-xtrace and others added 3 commits March 31, 2026 18:28
* 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
@liwenXtrace liwenXtrace merged commit 0f8522e into main Apr 1, 2026
10 checks passed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

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.[/]")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Comment thread CHANGELOG.md

- 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web


async def _embed_all() -> list[Any]:
if max_parallel_embeddings is not None:
sem = asyncio.Semaphore(max_parallel_embeddings)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Additional Locations (1)
Fix in Cursor Fix in Web

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.

2 participants