bad argument in call to crypto:aes_cfb_128_crypt - erlang

This is the code snippet at line 461 which is giving badarg error ,please help me solve this error guys.
ejabberd_odbc:escape(base64:encode(crypto:aes_cfb_128_encrypt(<<"abcdefghabcdefgh">>, <<"12345678abcdefgh">>, xml:element_to_binary(NewPacket)))),
Log:
bad argument in call to crypto:aes_cfb_128_crypt(<<"abcdefghabcdefgh">>, <<"12345678abcdefgh">>, <<">, true) in mod_offline:'-store_offline_msg/6-fun-2-'/2 line 225

One of the things I like about functional languages is that you generally have an easier time reproducing errors in a controlled environment. In your case, it seems like
base64:decode(XML)
is the call that's failing, so you should write
io:format("XML=~p~n", [XML]),
base64:decode(XML)
the first line will print out the contents of XML in Erlang syntax, and the second line will fail when you get to the bad input.
Once you see the string you're trying to decode, the problem will probably be obvious (it's not a string or it's not a base64 string). If it is a correctly-encoded base64 string, then you can post that problem as a StackOverflow question and get a more useful response.

Related

How do I solve the "attempt to call a table value" runtime error on lua?

I'm working on a lua script to convert IO Link data into MQTT. When I debugged the script, I got following runtime error on the function client:register :
Runtime error: attempt to call a table value (global 'string')
I understood that out of the 3 parameters needed, the eventname has to be in string. Coming from Java, I tried converting it directly in the function. It looks like this:
client:register( deviceHandle, string(IOhandleOnDisconnected) , IOhandleOnDisconnected )
It still does not work though.
Does anybody have an idea how to fix this?
Greetings.
string is Lua's standard library for string manipulation. It is a Lua table which cannot be called as you did in string(IOhandleOnDisconnected)

How do I find the error details using the match function on Lua?

I'm just asking a question on finding error details from the error function.
Like I would like to find error details from example.lua:50: "then" expected near "if".
Any ways on how to do that on Lua? I'm working on something for ComputerCraft on Lua. (Minecraft Java mod)
EDIT:
I'm trying make a function that returns the error parsed out. It's supposed to return 3 variables, var1: file name, var2: line number (if none it is specified nil), var3: error text.
example.lua is the file where the error is. 50 is the line number. There is a syntax error, likely in the if condition. (I'm not familiar with ComputerCraft, so I don't know where that file might be.)

SearchIO.parse xml blast and ampersands cElementTree.ParseError: not well-formed (invalid token) error

I would like some advice to work around an xml parsing error. In my BLAST xml output, I have a description that has an '&' character which is throwing off the SearchIO.parse function.
If I run
qresults=SearchIO.parse(PLAST_output,"blast-xml")
for record in qresults:
#do some stuff
I get the following error:
cElementTree.ParseError: not well-formed (invalid token): line 13701986, column 30
Which directs me to the this line:
<Hit_def>Lysosomal & prostatic acid phosphatases [Xanthophyllomyces dendrorhous</Hit_def>
Is there a way to override this in biopython so I do not have to change my xml file? Right now, I'm just doing a 'Try/Except' loop, but that is not optimal!
Thanks for your help!
Courtney

NSXMLParser fails with NSXMLParserErrorDomain error 111; error 111 isn't defined?

A few people seem to have run into NSXMLParser error 111 before, but it's not defined in the constants. This answer seems to have mistaken 111 with 11: NSXMLParserErrorDomain 111
As far as I can tell, I have no illegal characters in my final xml:
<?xml version="1.0" encoding="utf-16"?><wsse:BinarySecurityToken wsu:Id="uuid:383b6148-1c27-45ab-963b-30e14af8154e" ValueType="http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">aHR0cCUzYSUyZiUyZnNjaGVtYXMueG1sc29hcC5vcmclMmZ3cyUyZjIwMDUlMmYwNSUyZmlkZW50aXR5JTJmY2xhaW1zJTJmbmFtZWlkZW50aWZpZXI9V3dEM2ozRzBobjE0MWFndkNWJTJmWERadmgwJTJiQ0xHV1hBblRLTmM4Qjc3N1UlM2QmaHR0cCUzYSUyZiUyZnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyZmFjY2Vzc2NvbnRyb2xzZXJ2aWNlJTJmMjAxMCUyZjA3JTJmY2xhaW1zJTJmaWRlbnRpdHlwcm92aWRlcj11cmklM2FXaW5kb3dzTGl2ZUlEJkF1ZGllbmNlPWh0dHBzJTNhJTJmJTJma21haW4ta2RzLWV1czItMC5jbG91ZGFwcC5uZXQlMmYmRXhwaXJlc09uPTEzOTQ3NjExODEmSXNzdWVyPWh0dHBzJTNhJTJmJTJmdG9sZWRvLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQlMmYmSE1BQ1NIQTI1Nj1iVTg4cWs2OFc3bmFxOEZFam1EVUFWSlQySzZ5cCUyYkxmdGR4SlFlWDhsYXclM2Q=</wsse:BinarySecurityToken>
I've also tried changing the encoding to utf-8, but it made no difference. What causes a parser to fail with error 111? Is the parser not set up correctly, or is the XML killing it?
In NSXMLParserError docs, it says:
The following error codes are defined by NSXMLParser. For error codes not listed here, see the <libxml/xmlerror.h> header file.
The number 111 isn't mentioned in this list, so we go to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml/xmlerror.h, and find the value:
XML_ERR_USER_STOP, /* 111 */
There isn't a lot of documentation on XML_ERR_USER_STOP in libxml2, but from reading the changeset, it looks like it's a fast-fail when the parser sees an unexpected EOF.
Referred DebugCN and Internet.
Turns out I was simply passing in an entirely wrong string. The XML chunk came from a larger JSON structure, which I then processed down to get the only XML part; yet when inited the parser, I used the wrong string to create the NSData. So make sure you aren't mixing variables up. I'm still not sure why error 111 isn't defined in the documentation, though.

Ruby on Rails jsonparse error

Already I have spent a lot time to resolve the issue but not getting the actual reason.
I have a issue during parsing the json, below is the my josn which i am trying to format.
ERROR: 757: unexpected token at '"{\"requestId\":\"2323423432\",\"bids\":\"[ {\\"adId\\":50000001, \\"bidNative\\":100,\\"clickPayload\\":\\"clickPayload-1\\", \\"impressionPayload\\":\\"236|458795|12345\\"}, {\\"adId\\":60000002, \\"bidNative\\":200,\\"clickPayload\\":\\"clickPayload-2\\", \\"impressionPayload\\":\\"236|458795|12345\\"}, {\\"adId\\":60000002, \\"bidNative\\":300,\\"clickPayload\\":\\"clickPayload-3\\", \\"impressionPayload\\":\\"236|458795|12345\\"}]\"}"'
actually wherever it shows 2 slashes there are actually 3, but i dont know why stack overflows editor shows like this.

Resources