What could be wrong in arrayDecode(base64Decode(tTempArray))?

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderator: Klaus

trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: What could be wrong in arrayDecode(base64Decode(tTempArray))?

Post by trevix » Sun Jan 09, 2022 6:42 pm

Have you arrived as a sample set of data known to fail with that function?
No.

The error line is

Code: Select all

put arrayDecode(base64Decode(tTempArray)) into gTempArray
but the LC errorDialog reports char 1 of line 68.

Code: Select all

465,68,1
253,68,1
253,68,1
241,17,1,libraryStack
It would have been very helpful if instead of 1 there was 4 (for arrayDecode) or 16 (for base64Decode).
How can we be sure that the problem lay on base64Decode and not on arrayDecode. After all, for what I remember, trying to arrayDecode a var that is not an array will interrupt the script. Isn't it so?

About the char number, is this a bug ? (but I remember most of the time the errors were reported like this)
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: What could be wrong in arrayDecode(base64Decode(tTempArray))?

Post by jacque » Sun Jan 09, 2022 6:49 pm

I'm just advocating for the dozens of users you and I keep seeing who are mystified when the LC IDE presents answer dialogs dumping machine-oriented raw error info with no further assistance.
Got it. Maybe we should ask LC if they want to include our lookup stack in the Plugins that ship with the product. They did that with Rinaldi's tools.

The explanation of the error codes and where to find the meanings is documented in the errorDialog entry in the dictionary but few read that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: What could be wrong in arrayDecode(base64Decode(tTempArray))?

Post by LCMark » Mon Jan 10, 2022 6:43 pm

It would have been very helpful if instead of 1 there was 4 (for arrayDecode) or 16 (for base64Decode).
How can we be sure that the problem lay on base64Decode and not on arrayDecode. After all, for what I remember, trying to arrayDecode a var that is not an array will interrupt the script. Isn't it so?
There's no char line because the error is only being reported at the `put` statement line which (presumably) has its `put` token at char 1 of the line...

As base64Decode never throws an error - it ignores 'invalid' chars in the input (the code for that function hasn't changed ever I don't think!) - the error must be generated by arrayDecode - the reason it isn't cited as that is because that function only indicates success or failure, it doesn't actually generate a specific error code (which, with hindsight, is perhaps a bit of an omission).

Now, to my knowledge, the only case where arrayDecode will fail is if it is given invalid input - i.e. something which is not the result of arrayEncode. I can't recall a single case of arrayEncode generating something which arrayDecode could not decode - all reported bugs of that ilk have always ended up being scripter error...

This means, the most likely reason for that line throwing an error here is that what is in tTempArray is not a valid base64-encoded-array-encoded value.

Assuming that, there are two possibilities here:
1. The file it is fetched from is somehow corrupted.
2. The fetch of the file failed, and there was some lingering value in tTempArray from something earlier in the handler.

In terms of (1), the best you can do is use try/catch around arrayDecode - and assume if an error is thrown that there's something up with the file on disk.

In terms of (2), you should be checking 'the result' after you fetch the file into tTempArray using 'put url ... into', to make sure it succeeded - if it is non-empty then don't attempt to decode.

Post Reply