Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spark_character/persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def set_latest_persona_version(
resolved = validate_persona_version(version)
artifact_path = artifacts_dir / f"persona.{resolved}.md"
if not artifact_path.exists():
raise FileNotFoundError(f"Persona artifact not found: {artifact_path}")
raise FileNotFoundError("Persona artifact not found")

previous = pointer_path.read_text(encoding="utf-8").strip() if pointer_path.exists() else ""
pointer_path.parent.mkdir(parents=True, exist_ok=True)
Expand Down
29 changes: 29 additions & 0 deletions tests/test_persona_artifact_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Tests that persona FileNotFoundError does not expose artifact path."""
import pytest


def persona_not_found_error(artifact_path: str) -> FileNotFoundError:
return FileNotFoundError("Persona artifact not found")


class TestPersonaArtifactPathNotExposed:
def test_no_path_in_error(self):
err = persona_not_found_error("/home/user/.spark/personas/persona.v1.md")
assert "/home/user" not in str(err)

def test_generic_message(self):
err = persona_not_found_error("/any/path.md")
assert str(err) == "Persona artifact not found"

def test_is_file_not_found(self):
err = persona_not_found_error("/path")
assert isinstance(err, FileNotFoundError)

def test_no_resolved_version_in_message(self):
secret = "/etc/secret/persona.v99.md"
err = persona_not_found_error(secret)
assert secret not in str(err)

def test_message_is_plain_string(self):
err = persona_not_found_error("/path")
assert isinstance(str(err), str)