Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error in xml feed creation when empty title is provided. #448

Closed
apeterson91 opened this issue Mar 27, 2022 · 5 comments · Fixed by #491
Closed

Improve error in xml feed creation when empty title is provided. #448

apeterson91 opened this issue Mar 27, 2022 · 5 comments · Fixed by #491
Labels
feature request 🗻 a feature request or enhancement next to consider for next release

Comments

@apeterson91
Copy link

I'm getting the following error when running rmarkdown::render for a distill article

Error in `xml_text<-.xml_node`(`*tmp*`, value = text) : 
  STRING_ELT() can only be applied to a 'character vector', not a 'list'

However this error only occurs only when the option draft: false or the YAML draft option is omitted.
If draft: true the article renders as it should.

My sessioninfo is as follows:

R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.3

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] rstudioapi_0.13 xml2_1.3.2 knitr_1.36 magrittr_2.0.2 downlit_0.4.0 R6_2.5.1 jpeg_0.1-9
[8] rlang_1.0.1 fastmap_1.1.0 fansi_0.5.0 stringr_1.4.0 highr_0.9 tools_4.1.2 xfun_0.28
[15] png_0.1-7 cli_3.1.0 jquerylib_0.1.4 htmltools_0.5.2 yaml_2.2.1 digest_0.6.29 rprojroot_2.0.2
[22] bookdown_0.24 sass_0.4.0 vctrs_0.3.8 rsconnect_0.8.18 distill_1.3.1 mime_0.12 memoise_2.0.0
[29] cachem_1.0.6 evaluate_0.14 rmarkdown_2.11 stringi_1.7.5 compiler_4.1.2 bslib_0.3.1 generics_0.1.1
[36] jsonlite_1.8.0 lubridate_1.8.0

@cderv
Copy link
Collaborator

cderv commented Mar 28, 2022

Hi,

Can you share more about your example so that I can reproduce ? rmarkdown::render_article() is not a function in the rmarkdown package so not sure I follow.

  • I tried the template article created from RStudio IDE and ran rmarkdown::render(): It succeeded with no issue, no matter the draft YAML key
  • I tried by creating a new blog project. I created a new post with draft option, and rendered the post and the website without error.

To look into this further, I need a reproducible project where this happens (a github repo with this ?) or detailled step to reproduce using one of the templates.

Please also do update all the packages to be sure past bugs are fixed.

Thank you

@cderv cderv added the reprex needs a minimal reproducible example label Mar 28, 2022
@apeterson91
Copy link
Author

My apologies.
The function in question is rmarkdown::render() though I usually use the Rstudio keyboard shortcut CMD+K.
You can see the article and github repo where this occurs at https://github.com/apeterson91/xstreetvalidated.

I had been working on an article, without trouble until it stopped working as intended. The error affects my attempt to render any article and built the site.

@apeterson91
Copy link
Author

gentle ping to see present status.

If you do a git clone of the current branch for the repo linked above you should be able to reproduce the error stated in the first post. If not, that may suggest something to do with my system.

@cderv
Copy link
Collaborator

cderv commented May 9, 2022

You get this error because you are providing an empty description. We currently handle no description that will default to title, but here you specifically set description to be empty string. This creates the issue when generating the XML feed.

https://github.com/apeterson91/xstreetvalidated/blob/78275569f99052ca373433ee49be37d16f3ef373/_posts/2021-10-09-bikes/bikes.Rmd#L3

title: "What's the Buzz around Bikes?"
description: |
author:
  - name: Adam Peterson
    url: https://apetersonsite.org/

I'll see how I can error more gracefully in this case. But you should either not provide a description field, or provide one which would be better.

@cderv cderv added feature request 🗻 a feature request or enhancement reprex needs a minimal reproducible example and removed reprex needs a minimal reproducible example labels May 9, 2022
@cderv cderv changed the title Error in rmarkdown::render_article for distill article Improve error in xml feed creation when empty title is provided. May 9, 2022
@cderv cderv added next to consider for next release and removed reprex needs a minimal reproducible example labels May 9, 2022
@apeterson91
Copy link
Author

Ah, understood – thanks for the help!

cderv added a commit that referenced this issue Aug 28, 2023
NULL in R gives empty list in JSON (when read back). Testing for NULL was not correct to default for `title` when no `description` is provided.

This is now handle correctly and should avoid cryptic error from XML writing. Fix #490 and fix #448
cderv added a commit that referenced this issue Aug 28, 2023
NULL in R gives empty list in JSON (when read back). Testing for NULL was not correct to default for `title` when no `description` is provided.

This is now handle correctly and should avoid cryptic error from XML writing. Fix #490 and fix #448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request 🗻 a feature request or enhancement next to consider for next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants