Skip to content

fix(python): run assets by path when the path is not a valid module name - #2584

Open
mustafa3rsan wants to merge 1 commit into
mainfrom
fix/python-asset-non-module-path
Open

fix(python): run assets by path when the path is not a valid module name#2584
mustafa3rsan wants to merge 1 commit into
mainfrom
fix/python-asset-non-module-path

Conversation

@mustafa3rsan

@mustafa3rsan mustafa3rsan commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Bruin turns an asset's file path into a dotted module name and runs it with uv run --module. When the path is not importable, the interpreter rejects it and the asset cannot run at all:

using module path: .claude.skills.my-assets.push_ad
>> python: Relative module names not supported

That covers any segment starting with a dot (.claude/, .github/ — a leading dot means "relative import") and any segment that is not a valid Python identifier (my-assets/, ad assets/, 2024/). The same file runs fine when executed by path; only the -m form is affected.

Fix: when the module name does not match ^[A-Za-z_]\w*(\.[A-Za-z_]\w*)*$, pass the file path to uv run instead of --module. Valid module paths keep the existing behaviour.

Verified with a @bruin-headed asset under .claude/…: Relative module names not supported / FAIL before, runs / PASS after, with secrets still injected.

One caveat: an asset executed by path gets sys.path[0] set to its own directory instead of the repo root, so imports rooted at the repo will not resolve there. Those assets could not run at all before, so nothing regresses — happy to add the repo root to PYTHONPATH in that branch if you want the two forms fully equivalent.

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fix all with Greploop Fix All in Conductor

Prompt To Fix All With AI
### Issue 1
pkg/python/uv.go:332-333
**Script mode bypasses pyproject dependencies**

When an invalid-module asset contains PEP 723 metadata and has a discovered `pyproject.toml`, passing the original file to `uv run` switches uv into script mode, causing dependencies provided only by the project to be unavailable.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(python): run assets by path when the..." | Re-trigger Greptile

Comment thread pkg/python/uv.go Outdated
bruin turns an asset's file path into a dotted module name and runs it with
`uv run --module`. Paths that are not importable — a leading dot (.claude/...), a
hyphen or a space in a segment — produce names the interpreter rejects with
'Relative module names not supported', so those assets could not run at all.
Fall back to passing the file path in that case; valid module paths are unchanged.
@mustafa3rsan
mustafa3rsan force-pushed the fix/python-asset-non-module-path branch from 28a23e0 to 36ea694 Compare August 22, 2026 07:35
@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "fix(python): run assets by path when the..." | Re-trigger Greptile

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