Skip to content

bug: create_event raises IndexError for empty string values #1700

@aerosta

Description

@aerosta

Did you check docs and existing issues?

  • I have read all the NeMo-Guardrails docs
  • I have updated the package to the latest version before submitting this issue
  • (optional) I have used the develop branch
  • I have searched the existing issues of NeMo-Guardrails

Python version (python --version)

Python 3.11.2

Operating system/version

macOS 26.2

NeMo-Guardrails version (if you must use a specific version and not the latest

No response

Describe the bug

create_event in nemoguardrails/actions/core.py checks v[0] == "$" after confirming v is a string. When v is an empty string (""), this raises IndexError: string index out of range.

This looks like an edge case in the $ prefix check for string values. Similar checks in other parts of the codebase use .startswith("$"), which handles empty strings safely.

Steps To Reproduce

import asyncio
from nemoguardrails.actions.core import create_event

asyncio.run(create_event(event={"_type": "SomeEvent", "param": ""}))

Expected Behavior

Empty string values should pass through unchanged without raising an error.

Actual Behavior

create_event raises IndexError: string index out of range when an event contains an empty string value.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions