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

[Bug]: Yaml in frontmatter parsing keep failing #1216

Open
zmzlois opened this issue Jun 27, 2024 · 3 comments
Open

[Bug]: Yaml in frontmatter parsing keep failing #1216

zmzlois opened this issue Jun 27, 2024 · 3 comments
Labels
🐞 bug Something isn't working

Comments

@zmzlois
Copy link
Contributor

zmzlois commented Jun 27, 2024

Version

System:
    OS: macOS 14.2.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 90.42 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 126.0.6478.127
    Edge: 126.0.2592.81
    Safari: 17.2.1
  npmPackages:
    @rspress/mdx-rs: ^0.5.7 => 0.5.7
    @rspress/plugin-shiki: ^1.23.1 => 1.23.1
    rspress: ^1.18.1 => 1.18.1

Details

after I added metadata tag in frontmatter (tried several formats, spacing) and it keeps failing:

error below

npm run dev

>site@0.0.1 dev
> rspress dev

🔥 Rspress v1.18.1

thread 'thread '<unnamed><unnamed>' panicked at ' panicked at crates/plugin_frontmatter/src/lib.rscrates/plugin_frontmatter/src/lib.rs::1414::3636:
:
Failed to parse yaml: title: DE20020 - Failed to get application hash list.
description: Error - DE20020 - Workaround and debug for error: Failed to get application hash list.
head:
  - - meta
    - name: og:title
      content: Error - DE20020 - Failed to get application hash list.
  - - meta
    - name: og:url
      content: https://docs.com/guide/error/de20020。: Error { kind: SCANNER, problem: "mapping values are not allowed in this context", problem_mark: Mark { line: 2, column: 69 } }Failed to parse yaml: title: DE20019 - Snapshot upload gave no results
description: Error - DE20019 - Workaround and debug for error: snapshot upload gave no results
head:
  - - meta
    - name: og:title
      content: Error - DE20019 - Snapshot upload gave no results
  - - meta
    - name: og:url
      content: https://docs.com/guide/error/de20019。: Error { kind: SCANNER, problem: "mapping values are not allowed in this context", problem_mark: Mark { line: 2, column: 69 } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

fatal runtime error: failed to initiate panic, error 5
fatal runtime error: failed to initiate panic, error 5
zsh: abort      npm run dev

My frontmatter in each file looks like:

---
title: BU10013 - package.json must have a name and version
description: Error - BU10013 - Why does package.json needs to have a name and version? What happens when we don't have one?
head: 
  - - meta
    - name: og:title
      content: Error - BU10013 - package.json must have a name and version
  - - meta
    - name: og:url 
      content: https://docs.com/guide/error/bu10013
---

I have also tried this (check the spacing betwee - -

---
title: BU10013 - package.json must have a name and version
description: Error - BU10013 - Why does package.json needs to have a name and version? What happens when we don't have one?
head: 
- - meta
   - name: og:title
      content: Error - BU10013 - package.json must have a name and version
- - meta
   - name: og:url 
      content: https://docs.com/guide/error/bu10013
---

Not entirely sure what did I do wrong as i was following this guide here:
https://rspress.dev/api/config/config-frontmatter#head

Reproduce link

https://github.com/ZephyrCloudIO/zephyr-documentation/tree/get-started

Reproduce Steps

clone the repo and run npm i && npm run dev

@zmzlois zmzlois added the 🐞 bug Something isn't working label Jun 27, 2024
@SoonIter
Copy link
Member

I think there is an error in the writing of yaml, and the yaml parse of mdx-rs conforms to the specification.

image

You can try this below

title: DE20019 - Snapshot upload gave no results
- description: Zephyr Error - DE20019 - Workaround and debug for error: snapshot upload gave no results
+ description: "Zephyr Error - DE20019 - Workaround and debug for error: snapshot upload gave no results"
head: 
  - - meta
    - name: og:title
      content: Zephyr Error - DE20019 - Snapshot upload gave no results
  - - meta
    - name: og:url 
      content: https://docs.zephyr-cloud.io/guide/error/de20019

@chenjiahan
Copy link
Member

Can we improve the error message for yaml syntax errors

@SoonIter
Copy link
Member

Can we improve the error message for yaml syntax errors

The current error messge of serde_yaml is complete and aligned with the specification of yaml, which can debug problems. We can try more on how to better show it.

Failed to parse yaml: <yaml-content>
Error { kind: SCANNER, problem: "mapping values are not allowed in this context", problem_mark: Mark { line: 2, column: 69 } }

But before that, mdx-rs should catch this panic in rust side to make it more friendly to users who doesn't know much about Rust.

web-infra-dev/mdx-rs#49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants