Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
@IntrusionCM I'm always open to new suggestions by keeping ego aside.
But I think you might have misunderstood my rant.
POST data was array because it was HTML form old style submission. It is something django framework does for you.
The variable mentioned in rant is later initialised as empty array and wasn't directly getting POST data but it was supposed to get json after processing.
JSON dumping done after for loop operation to store JSON directly into Postgres database as JSONField.
But apart from all this shit, thanks for suggestion about nd json.
Well, the sender had to convert it to string because json doesn't really do arrays. If you expected it to be an array every time, then you should've converted it back first using numpy or some shit. I mean, print is not going to return an error because it got its favorite type.
@NoMad I think my English is the problem here.
I know sender will send a json string. But as you can see my reply to @IntrusionCM.
This part of code is not about accepting POST data.
It is already accepted properly by request.POST.getlist() method which is Django framework's in built method to convert JSON string array to proper array of dict.
My rant is about another variable which initialises empty array and receives values after processing of above array of dict.
This variable is again converted to JSON string to store in database JSON field.
@scorpionk in your first response, you said it was supposed to get json after processing. Even after processing, json won't really touch the values because it could potentially corrupt them. So it waits for you to convert them.
Also, getlist just gets a list of values for the mentioned key. It doesn't automatically convert.
Your English is fine. I didn't really read your comments in detail.
I think I understood what ScorpionK meant. And stackoverflow.... Leave that toxic pile of garbage, it's useless.
@scorpionk Good rant :)
So to sum it up, the error was in parsing the value (which was extracted from POST).
And someone initialized an variable holding the value with  / list, but overwrote it with a string.
Hence you assumed that the variable was a list, but fell flat - as it was a string representing an empty list.
That gives me some trolling ideas. Thanks!
@netikras If u meant feeding POST data which might not be "expected"...
My top 4 is:
1) empty string / string of control characters ( /r/n /t ...)
2) invalid JSON or JSON containing values that are not supported in some languages (64 bit unsigned integer...)
3) testing the limit by sending exponentially larger data... some APIs or better servers can be easily shutdown by sending large bulk data ... OOPS it OOMed again....
4) Stress testing all 3 and waiting if the server / any server dies due to missing HD space (faulty error propagation, noone should try to write an 100MB string in a log)
Till now the number of surviving API endpoints is quite low. Russian method for the win...
@IntrusionCM I'd be careful about #3 and #4. This is no longer playful trolling - it could be classified as a legitimate DoS attack.
Playful trolling is when people spend time trying to find a bug that never existed.
Taking/slowing a service down is far beyond the line and makes you an offender
@netikras Yes. I think I'll write a short rant about it, as I've gotten bit curious.
As I said, I'm not a free lancer.... And I would never run such tests against prod... For many many good reasons xD
I'll do these tests usually when a new API endpoint is "born"... Just to get a valid first impression of it.
When there is no dev ... I'll have an 64 GiB RAM playground server where I can do whatever the fuck I want to do. XD
this is why strict typing is a useful feature of useful languages