Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] ActionBinding - Resolution in matching entity throwing InvalidCastException when using Custom List Entities #139

Closed
AndreMantas opened this issue May 30, 2017 · 1 comment
Labels
question Further information is requested. Stack Overflow candidate

Comments

@AndreMantas
Copy link

AndreMantas commented May 30, 2017

I faced a problem yesterday when the user typed a value that is a list entity which would cause an InvalidCastException to be thrown in the ActionBinding project.

Exception message: Object must implement IConvertible

After some debugging (pictures attached) I found the problem and came up with a temporary fix.

In LuisActionResolver.cs (line ~445)

Before:

if (matchingEntity != null)
{
	var paramValue = matchingEntity.Resolution != null && matchingEntity.Resolution.Count > 0
		? matchingEntity.Resolution.First().Value
		: matchingEntity.Entity;

	result &= AssignValue(action, property, paramValue);
}

After:

if (matchingEntity != null)
{
	var paramValue = matchingEntity.Resolution != null && matchingEntity.Resolution.Count > 0
		? matchingEntity.Resolution.First().Value
		: matchingEntity.Entity;

	if (paramValue is JArray)
	{
		paramValue = (paramValue as JArray).First();
	}

	result &= AssignValue(action, property, paramValue);
}

(and the required imports)

It works for me since I don't have the same synonym in multiple entries.

I could create a pull request but I'm not sure if this is the best approach to solve the problem.

1

2

@nwhitmont
Copy link
Contributor

@AndreMantas
If you still have questions, please open a new issue on BotBuilder repo here: https://github.com/Microsoft/BotBuilder

@nwhitmont nwhitmont changed the title [ActionBinding] Resolution in matching entity throwing InvalidCastException when using Custom List Entities [Question] ActionBinding - Resolution in matching entity throwing InvalidCastException when using Custom List Entities Jul 5, 2017
@nwhitmont nwhitmont added .NET SDK question Further information is requested. Stack Overflow candidate labels Jul 5, 2017
willportnoy added a commit that referenced this issue Sep 14, 2017
…entitiesfix

[C# - Luis Action Binding] Fix to issue #139 & improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested. Stack Overflow candidate
Projects
None yet
Development

No branches or pull requests

2 participants