# fix: escape trail enablement probe path components

`ce0119b`→[main](/content/gh/entireio/cli/commits/main/index.html)·

dipree·1mo ago·2 files·+30 added/-1 removed

## Sessions

c5e00034c418View transcript

[?\
Inject Trail Context into Agent ModelPi·Opus 4.8·1 step](/content/gh/entireio/cli/session/019ecbec-8bcf-7f35-a647-2fc26c08a22e#timeline-c5e00034c418/index.html)

## Changes

2

- cmd/entire/cli/api

- Mtrails.go+3/-1

- Mtrails\_test.go+27

```
4 unmodified lines

5
6
7
8
9
10
11
5 unmodified lines

17
18
19
19
20
21
22
23
24

4 unmodified lines

"fmt"
	"io"
	"net/http"
	"net/url"

// TrailsEnabled reports whether the trails feature is enabled for the repo on
5 unmodified lines

// "couldn't reach the API" outcome is distinguishable from a definitive
// "not enabled".
func (c *Client) TrailsEnabled(ctx context.Context, forge, owner, repo string) (bool, error) {
	resp, err := c.Get(ctx, fmt.Sprintf("/api/v1/trails/%s/%s/%s?limit=1", forge, owner, repo))
	resp, err := c.Get(ctx, fmt.Sprintf("/api/v1/trails/%s/%s/%s?limit=1",
		url.PathEscape(forge), url.PathEscape(owner), url.PathEscape(repo)))
	if err != nil {
		return false, fmt.Errorf("probe trails enablement: %w", err)
	}
}

Mcmd/entire/cli/api/trails.go+3/-1

```
6 unmodified lines

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

6 unmodified lines

"testing"
)

func TestClient_TrailsEnabledEscapesPathComponents(t *testing.T) {
	t.Parallel()

var gotURI string
	server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		gotURI = r.RequestURI
		w.WriteHeader(http.StatusOK)
		w.Write([]byte(`{"trails":[]}`)) //nolint:errcheck // test handler
	}))
	defer server.Close()

c := NewClient("tok")
	c.baseURL = server.URL

ok, err := c.TrailsEnabled(context.Background(), "g/h", "acme?org", "repo#frag")
	if err != nil {
		t.Fatalf("TrailsEnabled: %v", err)
	}
	if !ok {
		t.Fatal("enabled = false, want true")
	}
	want := "/api/v1/trails/g%2Fh/acme%3Forg/repo%23frag?limit=1"
	if gotURI != want {
		t.Errorf("request URI = %q, want %q", gotURI, want)
	}
}

func TestClient_TrailsEnabled(t *testing.T) {
	t.Parallel()
