-
Notifications
You must be signed in to change notification settings - Fork 59
[BUG] The error capturing mechanism is lossy in an edge case #307
Comments
I guess the expected behaviour according to current naming conventions (pre #308 ) would be to generate the filename by taking the last ID from the search query rather than the result. This would lead to the files being named correctly regardless of them being empty. If the error files are empty, too, we could even consider adding a dummy message to the error file, indicating that there were no returns. I think some kind of arbitrary naming convention to prevent these files from overwriting each other should be implemented regardless of whether we keep the current convention or employ hashes. Even if they didn't produce errors, these empty files may lead to confusion on the user side |
I've done some testing and it seems the error_.json files are always empty. This seems strange, since I would expect the Twitter API to respond with some kind of error if no tweets can be retrieved. Any idea what the API response in these cases would be? |
@TimBMK It is not always empty. For example, in the case above the require(academictwitteR)
#> Loading required package: academictwitteR
FFF <- c("1266876474440761346", "1266868259925737474", "1266867327079002121", "1266866660713127936", "1266864490446012418", "1266860737244336129", "1266859737615826944", "1266859455586676736", "1266858090143588352", "1266857669157097473")
bogus <- rep("1", 200)
dirty <- c(bogus, FFF)
emptydir <- academictwitteR:::.gen_random_dir()
hydrate_tweets(ids = dirty, data_path = emptydir, bind_tweets = FALSE, errors = TRUE)
#> Batch 1 out of 3 : ids 1 to 1
#> Batch 2 out of 3 : ids 1 to 1
#> Batch 3 out of 3 : ids 1266876474440761346 to 1266857669157097473
jsonlite::read_json(file.path(emptydir, "errors_.json"), simplifyVector = TRUE)
#> value detail title resource_type
#> 1 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 2 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 3 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 4 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 5 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 6 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 7 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 8 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 9 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 10 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 11 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 12 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 13 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 14 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 15 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 16 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 17 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 18 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 19 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 20 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 21 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 22 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 23 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 24 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 25 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 26 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 27 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 28 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 29 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 30 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 31 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 32 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 33 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 34 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 35 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 36 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 37 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 38 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 39 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 40 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 41 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 42 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 43 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 44 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 45 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 46 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 47 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 48 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 49 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 50 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 51 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 52 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 53 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 54 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 55 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 56 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 57 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 58 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 59 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 60 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 61 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 62 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 63 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 64 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 65 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 66 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 67 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 68 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 69 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 70 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 71 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 72 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 73 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 74 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 75 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 76 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 77 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 78 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 79 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 80 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 81 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 82 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 83 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 84 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 85 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 86 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 87 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 88 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 89 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 90 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 91 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 92 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 93 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 94 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 95 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 96 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 97 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 98 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 99 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> 100 1 Could not find tweet with ids: [1]. Not Found Error tweet
#> parameter resource_id type
#> 1 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 2 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 3 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 4 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 5 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 6 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 7 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 8 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 9 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 10 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 11 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 12 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 13 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 14 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 15 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 16 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 17 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 18 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 19 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 20 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 21 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 22 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 23 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 24 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 25 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 26 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 27 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 28 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 29 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 30 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 31 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 32 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 33 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 34 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 35 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 36 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 37 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 38 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 39 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 40 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 41 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 42 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 43 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 44 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 45 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 46 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 47 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 48 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 49 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 50 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 51 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 52 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 53 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 54 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 55 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 56 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 57 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 58 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 59 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 60 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 61 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 62 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 63 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 64 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 65 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 66 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 67 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 68 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 69 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 70 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 71 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 72 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 73 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 74 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 75 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 76 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 77 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 78 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 79 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 80 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 81 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 82 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 83 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 84 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 85 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 86 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 87 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 88 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 89 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 90 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 91 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 92 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 93 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 94 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 95 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 96 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 97 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 98 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 99 ids 1 https://api.twitter.com/2/problems/resource-not-found
#> 100 ids 1 https://api.twitter.com/2/problems/resource-not-found Created on 2022-03-11 by the reprex package (v2.0.1) |
Interesting! In this case I would definetly opt for a stringent naming convention based on either the search query (last ID) or a hash. This would allow users to track issues and find out why their tweets were not retrieved. I'm looking at implementing the error capture mechanism more stringently into other functions such as get_user_timeline() at the moment. For this one at least, the errors seem to be empty in some cases. But this might be related to the actual API response, then. |
Please confirm the following
something went wrong. Status code: 400.
Describe the bug
The error capturing mechanism introduced since 1404bc3 (#264) is lossy in an edge case when at least two batches are all errors. It is due to the so-called "dirty road" problem: in the case of all errors, there is no
data
slot fordf_to_json
and thus the file name storingerrors
content will beerrors_.json
. When the second batch of all errors needs to be saved, it will also save aserrors_.json
and overwrite the old one.academictwitteR/R/utils.R
Lines 152 to 163 in 2809432
It is related to both #304 #305
Expected Behavior
I don't know. @TimBMK any thought?
Steps To Reproduce
In the following example, the vector
dirty
contains 200 bogus tweet ids. But the error capturing mechanism can only capture 100.Created on 2022-03-10 by the reprex package (v2.0.1)
Environment
Created on 2022-03-10 by the reprex package (v2.0.1)
Anything else?
No response
The text was updated successfully, but these errors were encountered: