[PR #5206] [MERGED] pkg/util/xlog: fix AddPrefix not updating existing prefix #5172

Closed
opened 2026-05-05 14:56:04 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/5206
Author: @fatedier
Created: 3/6/2026
Status: Merged
Merged: 3/6/2026
Merged by: @fatedier

Base: devHead: new


📝 Commits (1)

  • 5430cd1 pkg/util/xlog: fix AddPrefix not updating existing prefix due to range value copy

📊 Changes

1 file changed (+4 additions, -3 deletions)

View changed files

📝 pkg/util/xlog/xlog.go (+4 -3)

📄 Description

Summary

  • Fix AddPrefix range value copy bug: for _, p := range l.prefixes creates a copy of each element, so assignments to p.Value and p.Priority only modify the local copy, not the original slice element
  • Updates to existing prefixes were silently lost
  • Use index-based access l.prefixes[i] to modify the original slice element, and add break since prefix names are unique

Impact

client/service.go:361 calls AddPrefix(Name:"runID") on every reconnection using the same logger instance. When runID changes, the old value would persist in log output instead of being updated.

Test plan

  • go vet ./pkg/util/xlog/... passes
  • go build ./pkg/util/xlog/... passes
  • Codex review confirmed fix is correct

🔄 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/fatedier/frp/pull/5206 **Author:** [@fatedier](https://github.com/fatedier) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@fatedier](https://github.com/fatedier) **Base:** `dev` ← **Head:** `new` --- ### 📝 Commits (1) - [`5430cd1`](https://github.com/fatedier/frp/commit/5430cd1f89caf22481a4ef43e01cdcad09d2e6cd) pkg/util/xlog: fix AddPrefix not updating existing prefix due to range value copy ### 📊 Changes **1 file changed** (+4 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `pkg/util/xlog/xlog.go` (+4 -3) </details> ### 📄 Description ## Summary - Fix `AddPrefix` range value copy bug: `for _, p := range l.prefixes` creates a copy of each element, so assignments to `p.Value` and `p.Priority` only modify the local copy, not the original slice element - Updates to existing prefixes were silently lost - Use index-based access `l.prefixes[i]` to modify the original slice element, and add `break` since prefix names are unique ## Impact `client/service.go:361` calls `AddPrefix(Name:"runID")` on every reconnection using the same logger instance. When `runID` changes, the old value would persist in log output instead of being updated. ## Test plan - [x] `go vet ./pkg/util/xlog/...` passes - [x] `go build ./pkg/util/xlog/...` passes - [x] Codex review confirmed fix is correct --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:56:04 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#5172
No description provided.