protect against empty config from quarto inspect#961
Conversation
…ig in quarto inspect. Closes #958
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
(This file was not canonically formatted before now, so there's some diff churn, apologies.) The important lines changed are line 115Add export type QuartoProjectConfig = {
dir: string;
config: {
project: {
type: string;
preview: {
serve: { /* */ };
};
};
format: Record<string, unknown> | string;
[key: string]: unknown;
};
files: {
input: string[];
config?: string[];
};
};Clearly what should have happened all along is that quarto-cli and quarto both use the exact same type declarations. Alas, this will all go away in the land of Quarto 2 anyway. line 274from function configHash(config: QuartoProjectConfig) {
return (config.files.config ?? []).reduce((hash, file) => {
return hash + fs.statSync(file).mtimeMs.toLocaleString();
}, "");
} |
juliasilge
left a comment
There was a problem hiding this comment.
It took me a bit here to understand why this is biting us in some situations now, when this code hasn't been changed in years. Here is what I understand:
Quarto 1.9.37 changed quarto inspect <file> so that even files outside any project now get a "project" block in the output. Now, if you have a situation where you have:
- No
_quarto.ymlanywhere up the directory tree - A
.qmdwith no YAML front matter
Then you end up on the code path where this crash happens and this bug gets exposed. The change in Quarto 1.9.37 brought this code path into use, when it never was before.
Thanks for finding the problem, @cscheid! 🙌
|
@cscheid I think we should add this to the extension CHANGELOG even though it is not technically in extension code. Can you add that before merging? |
This PR reconciles output types with quarto-cli and protects against empty config in
quarto inspect.There's so many code smells in this file, it's all a bit terrifying. But this is a localized fix.
Closes #958.