Issue UI: fix config file resolution (#23832)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
Thomas Speer 2025-09-26 12:48:38 +02:00 • committed by GitHub
parent 0880f82c65
commit 4a4027c766
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 7 deletions

View file

@ -143,10 +143,10 @@
<template #description>
<p class="text-muted small">
{{ $t("issue.additional.yamlConfigDescription") }}<br />
<span v-if="configPath"
>{{ $t("issue.additional.source") }}:
<code>{{ configPath }}</code></span
>
<span>
{{ $t("issue.additional.source") }}:
<code>{{ configPath || "---" }}</code>
</span>
</p>
</template>
</IssueAdditionalItem>
@ -427,13 +427,21 @@ export default defineComponent({
try {
const response = await api.get("config/evcc.yaml", {
responseType: "text",
validateStatus: (code) => [200, 404].includes(code),
});
// Handle 404 silently when evcc.yaml doesn't exist
if (response.status === 404) {
this.sections.yamlConfig.content = "no yaml configuration";
return;
}
// Remove empty lines from config
this.sections.yamlConfig.content = response.data
.split("\n")
.filter((line: string) => line.trim() !== "")
.join("\n");
} catch (error) {
} catch (error: any) {
console.error("Failed to fetch config:", error);
this.sections.yamlConfig.content = "Failed to load configuration";
}

View file

@ -294,7 +294,7 @@ func runRoot(cmd *cobra.Command, args []string) {
// publish system infos
valueChan <- util.Param{Key: keys.Version, Val: util.FormattedVersion()}
valueChan <- util.Param{Key: keys.Config, Val: cfgFile}
valueChan <- util.Param{Key: keys.Config, Val: viper.ConfigFileUsed()}
valueChan <- util.Param{Key: keys.Database, Val: db.FilePath}
// run shutdown functions on stop
@ -343,7 +343,7 @@ func runRoot(cmd *cobra.Command, args []string) {
log.INFO.Println("evcc was stopped by user. OS should restart the service. Or restart manually.")
err = errors.New("restart required") // https://gokrazy.org/development/process-interface/
once.Do(func() { close(stopC) }) // signal loop to end
}, cfgFile)
}, viper.ConfigFileUsed())
// show and check version, reduce api load during development
if util.Version != util.DevVersion {