Error when uploading a new version of an image attachment
I have periodically received the following error when modifying an existing page using confl_create_post_from_Rmd(), with update = T. Manually re-uploading the attached images within the browser sometimes seems to fix the problem (allowing me to then upload further attachment versions via confl_create_post_from_Rmd). Otherwise, I have to delete and recreate the page. Any thoughts on what would cause this?
Checking the existing images...
Uploading the images...
Error: Error in paste(httr::http_condition(res, type = "error"), httr::content(res)): Bad Request (HTTP 400).
400
Error in paste(httr::http_condition(res, type = "error"), httr::content(res)): Bad Request (HTTP 400).
list(authorized = FALSE, valid = TRUE, errors = list(), successful = FALSE)
Error in paste(httr::http_condition(res, type = "error"), httr::content(res)): Bad Request (HTTP 400).
com.atlassian.confluence.api.service.exceptions.BadRequestException: Cannot add a new attachment with same file name as an existing attachment: <filename>
Run `rlang::last_error()` to see where the error occurred.
Hmm, curious. conflr checks the existing attachments and depending on whether there's the one with the same title (i.e., filename), it chooses the proper method. But, the error Cannot add a new attachment with same file name as an existing attachment indicates conflr failed to match the title for some reason. Do you know there's some conversion on the filename after uploading to your Confluence?
https://github.com/line/conflr/blob/0ef4cfefb6163ee42044cab5f2a7637556240ea8/R/addin-internals.R#L63-L66
https://github.com/line/conflr/blob/0ef4cfefb6163ee42044cab5f2a7637556240ea8/R/addin-internals.R#L76-L81
Thanks for responding so quickly. The filenames seem to be consistent between the Confluence attachments and what I have locally. For reference, I am using Atlassian Cloud. The issue also seems to be pretty intermittent. Sometimes I'm able to upload 3 different versions of a file before the issue occurs. Other times, I'm only able to upload one.
I am having a similar issue in which I use the "Post to Confluence" add-in on an already-published page (Confluence Cloud). If I have converted to the new editor (which is the default style for my organization) the images will not update. You get a grey square with a loading icon. It has become extremely inconvenient. We've been experiencing this problem for a week or two now.
One workaround is to delete the Confluence page and start from scratch. But not all users have delete permissions. I have had some success reverting back to the old editor in Page History, then updating, but this is clunky too.
@elliotlayden Thanks for confirmation.
Sometimes I'm able to upload 3 different versions of a file before the issue occurs. Other times, I'm only able to upload one.
This sounds like there's some API limit and conflr fails to detect the error returned by the API, but I'm not sure...
@stevenlockton-progenity Thanks for sharing, but it sounds a different issue to me. It's just that conflr doesn't support the new editor format yet (as you let us know in #125), right?
@elliotlayden - hi - yes, I'm aware :) I was chipping in because this new issue is related to updating image attachments (albeit it only manifests itself in the new editor).
confl_list_attachments <- function(id, filename = NULL, mediaType = NULL, start = 0, limit = 50, expand = NULL)
https://github.com/line/conflr/blob/0ef4cfefb6163ee42044cab5f2a7637556240ea8/R/addin-internals.R#L63-L66
When uploading, there is no way to provide limit,
and it causes issues, if there are more than 50 images.
Ahh, thank you so much for catching!!!
confl_list_attachments() is used here to see if there's already the same name of the images; since it errors if we try to create the duplicated one, we need to the "update" API instead of the "create" API. So, probably it matters here...
Note that I'm not sure if that explains all the errors reported here, though. There might be something specific to the new editor.