[PR #2727] [MERGED] Fix fatal error on missing config file #2821

Closed
opened 2025-12-29 04:19:11 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2727
Author: @oneingan
Created: 8/14/2025
Status: Merged
Merged: 10/19/2025
Merged by: @nblock

Base: mainHead: patch-1


📝 Commits (1)

  • a9933f7 Fix fatal error on missing config file by handling viper.ConfigFileNotFoundError

📊 Changes

1 file changed (+5 additions, -5 deletions)

View changed files

📝 hscontrol/types/config.go (+5 -5)

📄 Description

This PR fixes a fatal error when no config file is found during CLI operations, ensuring consistent behavior with empty config files. Previously, LoadConfig incorrectly checked for fs.ErrNotExist instead of Viper's ConfigFileNotFoundError, causing the CLI to fail for commands like headscale nodes list when relying on environment variables (e.g., HEADSCALE_CLI_ADDRESS). Now, a missing config file logs a warning and falls back to defaults, matching the empty config file case.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/2727 **Author:** [@oneingan](https://github.com/oneingan) **Created:** 8/14/2025 **Status:** ✅ Merged **Merged:** 10/19/2025 **Merged by:** [@nblock](https://github.com/nblock) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`a9933f7`](https://github.com/juanfont/headscale/commit/a9933f72662483ac78d58fc1521cdd730d7a9bf4) Fix fatal error on missing config file by handling viper.ConfigFileNotFoundError ### 📊 Changes **1 file changed** (+5 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `hscontrol/types/config.go` (+5 -5) </details> ### 📄 Description This PR fixes a fatal error when no config file is found during CLI operations, ensuring consistent behavior with empty config files. Previously, `LoadConfig` incorrectly checked for `fs.ErrNotExist` instead of Viper's `ConfigFileNotFoundError`, causing the CLI to fail for commands like `headscale nodes list` when relying on environment variables (e.g., `HEADSCALE_CLI_ADDRESS`). Now, a missing config file logs a warning and falls back to defaults, matching the empty config file case. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 04:19:11 +01:00
adam closed this issue 2025-12-29 04:19:11 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2821