Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug in set_value of StateManager #1908

@RobinVds

Description

@RobinVds

Version

Latest

Describe the bug

When I try to set the state value via the state manager I get the following error:

  File "/home/robin/dev/ask-waldo/ask-waldo-teams-chatbot/.venv/lib/python3.8/site-packages/botbuilder/dialogs/memory/dialog_state_manager.py", line 293, in try_get_value
    i_first = path.upper().rindex(first)
ValueError: substring not found

To Reproduce

Steps to reproduce the behavior:
Call set_value on state_manager:
step_context.state.set_value("user.path", "a value")

Expected behavior

I do not receive an error and the state is updated.

Additional context

This can be fixed as follows:
In file: botbuilder-python/libraries/botbuilder-dialogs/botbuilder/dialogs/memory/dialog_state_manager.py

Update:
i_first = path.upper().rindex(first)

To:

        try:
            i_first = path.upper().rindex(first)
        except ValueError:
            i_first = -1

Or just fix that hacky thing that is being done there :)

Metadata

Metadata

Assignees

Labels

Bot ServicesRequired for internal Azure reporting. Do not delete. Do not change color.bugIndicates an unexpected problem or an unintended behavior.customer-replied-toIndicates that the team has replied to the issue reported by the customer. Do not delete.customer-reportedIssue is created by anyone that is not a collaborator in the repository.needs-triageThe issue has just been created and it has not been reviewed by the team.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions