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

Undefined array key exception when creating Markdown pages with only front matter and no Markdown #1705

Closed
caendesilva opened this issue Apr 30, 2024 · 3 comments · Fixed by spatie/yaml-front-matter#41 or #1728
Labels
bug Something isn't working

Comments

@caendesilva
Copy link
Member

Creating a file just like this (for example _pages/foo.md) causes a discovery exception

---
foo: bar
---
   RuntimeException

  An error occurred during the discovery process: Undefined array key 0

  at packages\framework\src\Foundation\Concerns\BaseFoundationCollection.php:54
     50▕         try {
     51▕             $this->runDiscovery();
     52▕             $this->runExtensionHandlers();
     53▕         } catch (Throwable $exception) {
  ➜  54▕             throw new RuntimeException("An error occurred during the discovery process: {$exception->getMessage()}", previous: $exception);
     55▕         }
     56▕
     57▕         return $this;
     58▕     }

  1   vendor\spatie\yaml-front-matter\src\ComplexMarkdownParser.php:87
      ErrorException::("Undefined array key 0")

  2   vendor\spatie\yaml-front-matter\src\ComplexMarkdownParser.php:87
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 0", "H:\monorepo\vendor\spatie\yaml-front-matter\src\ComplexMarkdownParser.php")

@caendesilva
Copy link
Member Author

Adding a newline solves this, but I think we should still handle this gracefully, so confirming this as a bug.

---
foo: bar
---

@caendesilva caendesilva added the bug Something isn't working label Apr 30, 2024
@caendesilva caendesilva changed the title Undefined array key 0 error when creating markdown pages with only front matter and no Markdown Undefined array key exception when creating Markdown pages with only front matter and no Markdown Apr 30, 2024
@caendesilva
Copy link
Member Author

I think this might best be handled in the upstream package, so gonna make a PR.

@caendesilva
Copy link
Member Author

Fixed by spatie/yaml-front-matter#41 through #1728

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
1 participant