"The given key was not present in the dictionary" error occurs randomly

Hi everyone, I have a problem with unattended bot. From time to time “The given key was not present in the dictionary” error occures during reading value from dictonary variable, althought the key exist and most of the time the bot reads the value without any issue. Is this a bug? Do you know any solution? Thank you in advance.

Hi @kamil
have you initialise the dictionary?

Ashwin S

Hi AshwinS2, yes variable is initialised correctly (bot creates a new dictonary), keys and values are assigned correclty, so there shouldn’t be a problem with reading values from the dictionary. Most of the time the bot works properly, it fails from time to time, and I don’t know why.

Hi welcome to the community!
I think it is very low chance that this would be a bug, but we would need to trace this problem with a try catch and in the catch you print the key you are trying to read and a list of all keys present in the dictionary at that time, so you make sure it was there…

We too had this problem .

Are you trying to set the transacation Status anywhere?

I am experiencing the same. Once in a while its not working. It feels pretty random. Any ideas anybody?

Hey @kamil,

I added the value to the key via an assign activity before.
The error didn’t seem to appear after I replaced it with an Invoke Method activity. I tried it 10+ times and so far so good #fingers crossed.
See an example below.

Please let me know if this worked out for you!

Nope. I am still getting it randomly.

I am having a similar issue with my bot. The process worked absolutely fine for the longest and all of a sudden it is giving me issues. It claims to error out due to a key not being present, but when I output the same value from the dictionary out to a Message Box and run in Debug mode, it displays the string in the Message Box as if it has no issue reading from the config file I have set up.

When I run outside of Debug mode, it doesn’t even display the text in the message box. Just fails. This has to be a bug.