[BUG] Cannot Add A Filter On Labels In Config Files If Their Names Contain Colons

by ADMIN 82 views

BUG: Cannot add a filter on labels in config files if their names contain colons

As a user of the extension, we appreciate your feedback and contributions to making it better. In this article, we will discuss a bug that has been reported by a user, where they were unable to create a filter in their config file that involves a label name containing a colon (:) sign. We will go through the steps to reproduce the behavior, the expected behavior, and the desktop information provided by the user.

The user reported that they were unable to create a filter in their config file that involves a label name containing a colon (:) sign. However, it works if you do this filtering in the UI, as expected. This bug is specific to the config file and does not occur when filtering in the UI.

To reproduce the behavior, follow these steps:

Step 1: Add a Filter in the Config File

In the issue or PR section of your config file, add a filter such as label:"Priority: High". For instance:

issuesSections:
- title: High Priority
  filters: label:"Priority: High :red_circle:"

Step 2: Launch gh dash

Launch gh dash to load the config file.

Step 3: Observe the Error

The dashboard won't launch, and an error will be thrown:

2025-03-13T18:37:50Z FATA <ui/ui.go:114> Reading config file: failed parsing config file location="" err="failed parsing config.yml: yaml: line 16: mapping values are not allowed in this context"

The user would expect that we can escape colons by wrapping the label filter in single or double quotes. This would allow them to create filters in their config file that involve label names containing colons.

The user provided the following desktop information:

  • OS: MacOS Sequoia 15.3.1

In conclusion, this bug prevents users from creating filters in their config file that involve label names containing colons. The expected behavior is that we can escape colons by wrapping the label filter in single or double quotes. We appreciate the user's feedback and contributions to making the extension better.

To fix this bug, we can modify the code to allow escaping colons by wrapping the label filter in single or double quotes. This would enable users to create filters in their config file that involve label names containing colons.

To implement this solution, we can modify the code as follows:

// In ui/ui.go
func readConfigFile(configFile string) error {
    // ...
    if strings.Contains(configFile, ":") {
        // Allow escaping colons by wrapping the label filter in single or double quotes
        configFile = strings.ReplaceAll(configFile, `label:"`, `label="`)
        configFile = strings.ReplaceAll(configFile, `label:`, `label: `)
    }
    // ...
}

To test this solution, we can create a test case that involves a label name containing a colon. We can then verify that the code allows escaping colons by wrapping the label filter in single or double quotes.

// In ui/ui_test.go
func TestReadConfigFile(t *testing.T) {
    configFile := `issuesSections:
- title: High Priority
  filters: label:"Priority: High :red_circle:"`
    // ...
}

By implementing these code changes and testing the solution, we can fix this bug and enable users to create filters in their config file that involve label names containing colons.
Q&A: Cannot add a filter on labels in config files if their names contain colons

In our previous article, we discussed a bug that prevents users from creating filters in their config file that involve label names containing colons. We also provided a possible solution to fix this bug. In this article, we will answer some frequently asked questions related to this bug and its solution.

A: The bug prevents users from creating filters in their config file that involve label names containing colons. When a user tries to create such a filter, the dashboard won't launch, and an error will be thrown.

A: This bug occurs because the code does not allow escaping colons by wrapping the label filter in single or double quotes. As a result, when a user tries to create a filter with a label name containing a colon, the code throws an error.

A: To reproduce this bug, follow these steps:

  1. Add a filter in your config file that involves a label name containing a colon, such as label:"Priority: High".
  2. Launch gh dash to load the config file.
  3. Observe the error that is thrown.

A: The expected behavior is that we can escape colons by wrapping the label filter in single or double quotes. This would allow users to create filters in their config file that involve label names containing colons.

A: To fix this bug, you can modify the code to allow escaping colons by wrapping the label filter in single or double quotes. This can be done by adding a check in the code to see if the label filter contains a colon, and if so, wrapping it in single or double quotes.

A: To implement this solution, you can modify the code as follows:

// In ui/ui.go
func readConfigFile(configFile string) error {
    // ...
    if strings.Contains(configFile, ":") {
        // Allow escaping colons by wrapping the label filter in single or double quotes
        configFile = strings.ReplaceAll(configFile, `label:"`, `label="`)
        configFile = strings.ReplaceAll(configFile, `label:`, `label: `)
    }
    // ...
}

A: To test this solution, you can create a test case that involves a label name containing a colon. You can then verify that the code allows escaping colons by wrapping the label filter in single or double quotes.

// In ui/ui_test.go
func TestReadConfigFile(t *testing.T) {
    configFile := `issuesSections:
- title: High Priority
  filters: label:"Priority: High :red_circle:"`
    // ...
}

In conclusion, this bug prevents users from creating filters in their config file that involve label names containing colons. The expected behavior is that we can escape colons by wrapping the label filter in single or double quotes. We have provided a possible solution to fix this bug, and we have answered some frequently asked questions related to this bug and its solution.