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

Nil pointer dereference in /json/search-data.json with .File.BaseFileName after upgrading to v0.8.5 #478

Open
nakednous opened this issue Oct 17, 2024 · 5 comments

Comments

@nakednous
Copy link

nakednous commented Oct 17, 2024

Description

After upgrading from Hextra v0.8.4 to v0.8.5, the site build fails due to an error in /json/search-data.json. The .File.BaseFileName property references a nil value, leading to a runtime error. The issue occurs on a multilingual site with English and a partial Spanish translation.

Steps To Reproduce

  1. Upgrade Hextra to v0.8.5.
  2. Run hugo server --buildDrafts --disableFastRender.
  3. Observe the error in the console.

Expected Behavior

The site should build successfully without errors.

Actual Behavior

The build fails with a nil pointer dereference error.

Screenshots

N/A

Environment

  • Hugo Version: v0.136.0
  • Browser/OS: Firefox, Arch Linux
  • Theme Version: v0.8.5

Additional Context

The log error is:

Error: error building site: EXECUTE-AS-TEMPLATE: failed to transform "/json/search-data.json" (application/json): template: /json/search-data.json:14:51: executing "/json/search-data.json" at <$page.File.BaseFileName>: error calling BaseFileName: runtime error: invalid memory address or nil pointer dereference
@imfing
Copy link
Owner

imfing commented Oct 17, 2024

Hi, thanks for reporting. Do you have the link to the site source or a minimal reproducible example?

@Gr3q
Copy link
Contributor

Gr3q commented Oct 18, 2024

Caused by this a97a179#diff-878d857f7dcdc7fd275c8ebd8d44c3894aee03519344b2cc1b55c079314a4bfeL10

The error is caused by a page that doesn't have a file, previously excluded because it didn't have Content either.

It could be fixed if pages without a File are excluded (??), but I'm also curious to see en example.

@imfing
Copy link
Owner

imfing commented Oct 19, 2024

Caused by this a97a179#diff-878d857f7dcdc7fd275c8ebd8d44c3894aee03519344b2cc1b55c079314a4bfeL10

The error is caused by a page that doesn't have a file, previously excluded because it didn't have Content either.

It could be fixed if pages without a File are excluded (??), but I'm also curious to see en example.

Right, that exclusion line is the only change we made. Not sure why page.File.BaseFileName would cause a nil pointer dereference panic, maybe could also be a Hugo bug?

@imfing
Copy link
Owner

imfing commented Oct 21, 2024

@Gr3q i'll revert the search-data line change for now as I saw another person ran into the same issue

@imfing
Copy link
Owner

imfing commented Oct 21, 2024

@Gr3q i'll revert the search-data line change for now as I saw another person ran into the same issue

done, cut a new release that reverts the change in search-data.json: https://github.com/imfing/hextra/releases/tag/v0.8.6

will look into the root cause when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants