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
11 changes: 11 additions & 0 deletions src/specify_cli/integrations/rovodev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ def _merge_prompt_entries(

for entry in existing:
name = entry.get("name", "")
# ``prompts.yml`` is user-editable, and ``_read_prompts_yml`` only
# filters at the entry level -- it never validates the entry's
# ``name``. A YAML sequence or mapping there is unhashable, so this
# dict-membership test raised a raw ``TypeError`` out of ``setup()``
# and aborted every ``specify init`` / ``integration install`` for
# rovodev on that project, leaving prompts.yml unwritten. A
# non-string name can never match a generated entry, so treat it
# like any other unmatched entry and preserve it verbatim.
if not isinstance(name, str):
merged.append(entry)
continue
if name in generated_by_name:
merged.append(generated_by_name[name])
seen.add(name)
Expand Down
39 changes: 39 additions & 0 deletions tests/integrations/test_integration_rovodev.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,45 @@ def test_prompt_wrapper_format(self, tmp_path):
f"{prompt_file} has unexpected wrapper format"
)

@pytest.mark.parametrize(
"bad_name",
[["speckit-plan", "speckit-tasks"], {"a": 1}],
ids=["sequence", "mapping"],
)
def test_prompts_manifest_merge_tolerates_non_scalar_name(
self, tmp_path, bad_name
):
"""An unhashable `name` in a user-edited prompts.yml must not crash setup.

`_read_prompts_yml` only filters at the entry level, never validating
the entry's `name`, so a YAML sequence or mapping there reached a dict
membership test and raised a raw `TypeError: unhashable type` out of
`setup()` — aborting every `specify init` / `integration install` for
rovodev on that project and leaving prompts.yml unwritten.
"""
impl = get_integration(self.KEY)
manifest = IntegrationManifest(self.KEY, tmp_path)

prompts_manifest = tmp_path / ".rovodev" / "prompts.yml"
prompts_manifest.parent.mkdir(parents=True, exist_ok=True)
prompts_manifest.write_text(
yaml.safe_dump(
{"prompts": [{"name": bad_name, "content_file": "prompts/x.md"}]}
),
encoding="utf-8",
)

impl.setup(tmp_path, manifest, script_type="sh")

data = yaml.safe_load(prompts_manifest.read_text(encoding="utf-8"))
names = [entry.get("name") for entry in data["prompts"]]
# The malformed user entry is preserved verbatim...
assert bad_name in names, names
# ...and the generated entries were still written.
assert any(
isinstance(n, str) and n.startswith("speckit-") for n in names
), names

def test_prompts_manifest_merge_preserves_user_entries(self, tmp_path):
impl = get_integration(self.KEY)
manifest = IntegrationManifest(self.KEY, tmp_path)
Expand Down