Nil pointer dereference in /json/search-data.json with .File.BaseFileName after upgrading to v0.8.5
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
- Upgrade Hextra to v0.8.5.
- Run
hugo server --buildDrafts --disableFastRender. - 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
Hi, thanks for reporting. Do you have the link to the site source or a minimal reproducible example?
Caused by this https://github.com/imfing/hextra/commit/a97a1791cc518d9d78d7fc54deead77d65877895#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.
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
Contenteither.It could be fixed if pages without a
Fileare 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?
@Gr3q i'll revert the search-data line change for now as I saw another person ran into the same issue
@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.