mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[PR #5194] [MERGED] Improve config loading error messages with line numbers #5162
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#5162
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fatedier/frp/pull/5194
Author: @fatedier
Created: 3/4/2026
Status: ✅ Merged
Merged: 3/4/2026
Merged by: @fatedier
Base:
dev← Head:claude/frpc-verify-error-details-EW9Pn📝 Commits (1)
8d000d0pkg/config: improve error messages with line number details for config parsing📊 Changes
2 files changed (+200 additions, -6 deletions)
View changed files
📝
pkg/config/load.go(+94 -6)📝
pkg/config/load_test.go(+106 -0)📄 Description
WHY
Configuration file parsing errors can be difficult to debug without knowing where in the file the problem occurs. This change enhances error reporting for TOML, JSON, and YAML configuration files by:
WHAT
Core Changes:
LoadConfigure()to accept an optional format hint parameterLoadConfigureFromFile()to detect format from file extension and pass it toLoadConfigure()detectFormatFromPath()to determine config format from file extension (.toml, .yaml, .yml, .json)formatTOMLError()to extract and format TOML decode errors with line/column informationenhanceDecodeError()to enhance JSON/YAML errors with field path and line number informationfindFieldLineInContent()to locate field definitions in the original config contentError Message Improvements:
toml: line X, column Y: error messageline X: field "fieldname": cannot unmarshal value into typeTests Added:
TestTOMLSyntaxErrorWithLineNumber: Verifies TOML syntax errors include line informationTestTOMLTypeMismatchErrorWithFieldInfo: Verifies type errors include field informationTestFindFieldLineInContent: Tests field line detection across various config structuresTestFormatDetection: Tests file format detection from extensionsTestValidTOMLStillWorks: Ensures valid configs continue to parse correctlyTest Plan
All new functionality is covered by unit tests in
pkg/config/load_test.go. The changes are backward compatible—existing code paths continue to work as before, with enhanced error messages as a bonus.https://claude.ai/code/session_017HWLfcXS3U2hLoy4dsg8Nv
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.