[PR #2953] [MERGED] fix: list-routes command now respects identifier filter with JSON output #2960

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

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2953
Author: @roganlynch
Created: 12/10/2025
Status: Merged
Merged: 12/10/2025
Merged by: @nblock

Base: mainHead: fix-issue-2927-list-routes-identifier-filter


📝 Commits (1)

  • 68766cf fix: list-routes command now respects identifier filter with JSON output

📊 Changes

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

View changed files

📝 cmd/headscale/cli/nodes.go (+5 -4)

📄 Description

Fixes #2927

Problem

In v0.27.0, the list-routes command with -i flag and -o json output was returning all nodes instead of just the specified node.

Root Cause

The JSON output was happening before the identifier filtering logic in the listNodeRoutesCmd function. When -i 12 -o json was specified, the function would output all nodes from response.GetNodes() and continue execution, never using the filtered nodes variable for JSON output.

Solution

Moved the JSON output block from before the filtering logic to after it, ensuring it outputs the nodes variable (which has been filtered by both identifier and route existence) instead of the unfiltered response.GetNodes().

Changes

  • Moved lines 231-233 (JSON output) to after line 245 (after filtering)
  • Changed output from response.GetNodes() to nodes (filtered variable)
  • Added early return after JSON output to prevent table rendering

Testing

This restores the v0.26.1 behavior where:

headscale nodes list-routes -i 12 -o json

correctly returns only node 12's route information instead of all nodes.


🔄 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/2953 **Author:** [@roganlynch](https://github.com/roganlynch) **Created:** 12/10/2025 **Status:** ✅ Merged **Merged:** 12/10/2025 **Merged by:** [@nblock](https://github.com/nblock) **Base:** `main` ← **Head:** `fix-issue-2927-list-routes-identifier-filter` --- ### 📝 Commits (1) - [`68766cf`](https://github.com/juanfont/headscale/commit/68766cf238b46a00c76c7588202b634b43f0704e) fix: list-routes command now respects identifier filter with JSON output ### 📊 Changes **1 file changed** (+5 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `cmd/headscale/cli/nodes.go` (+5 -4) </details> ### 📄 Description Fixes #2927 ## Problem In v0.27.0, the `list-routes` command with `-i` flag and `-o json` output was returning all nodes instead of just the specified node. ## Root Cause The JSON output was happening **before** the identifier filtering logic in the `listNodeRoutesCmd` function. When `-i 12 -o json` was specified, the function would output all nodes from `response.GetNodes()` and continue execution, never using the filtered `nodes` variable for JSON output. ## Solution Moved the JSON output block from before the filtering logic to after it, ensuring it outputs the `nodes` variable (which has been filtered by both identifier and route existence) instead of the unfiltered `response.GetNodes()`. ## Changes - Moved lines 231-233 (JSON output) to after line 245 (after filtering) - Changed output from `response.GetNodes()` to `nodes` (filtered variable) - Added early return after JSON output to prevent table rendering ## Testing This restores the v0.26.1 behavior where: ```bash headscale nodes list-routes -i 12 -o json ``` correctly returns only node 12's route information instead of all nodes. --- <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:49 +01:00
adam closed this issue 2025-12-29 04:19:50 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2960