Skip to content

Unclear error message when using code chunk options with yaml and an extra space is present #4306

Closed
@coatless

Description

@coatless

Bug description

This issue came up earlier today when a student was having problems identifying why their quarto document wasn't able to be rendered.

In particular, the student accidentally spaced the code chunk option one extra, that is:

```{sql}
#| label: test multiqueries -5
#|  connection: db
-- ^ note the extra space

select 1
```

Thus, when the Quarto document was rendered, we were seeing:

processing file: my-homework.qmd
Error in yaml::yaml.load(meta, handlers = list(expr = parse_only)) : 
  Scanner error: mapping values are not allowed in this context at line 2, column 12
Calls: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Execution halted

This is a misleading error as it implies that the error falls inside of the document customization header. Instead, the error was related to a code chunk option.

Would it be possible to provide more localized support for bad code chunk specification?

my-homework.qmd :

---
title: "Example"
format: pdf
engine: knitr
editor: visual
---

```{r}
# install.packages(c("DBI", "RSQLite"))
db = DBI::dbConnect(RSQLite::SQLite(), ":memory:")
```


```{sql}
#| label: test multiqueries -5
#|  connection: db

select 1
```

Version information:

  • RStudio: 2022.12.0.353
  • Quarto: 1.2.313
  • Operating System: macOS

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.

Metadata

Metadata

Assignees

Labels

documentationDoc improvements & quarto-webenhancementNew feature or requestupstreamBug is in upstream library

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions