Skip to content

[BUG] Fail to set ACL policy file with etag which is got from Get API #27

Open
@KanShiori

Description

@KanShiori

go version: 1.24.0
version tailscale.com/client/tailscale/v2 v2.0.0-20250509161557-5fad10cf3a33

My code is like:

acl, err := ts.PolicyFile().Get(context.TODO())
Expect(err).To(BeNil())

// modify acl here

err = ts.PolicyFile().Set(context.TODO(), *acl, acl.ETag)
Expect(err).To(BeNil())

And I got an error: precondition failed, invalid old hash (412).

The root cause is using fmt.Sprintf("%q", etag) to set the etag header in the Set function, it adds extra double quotes.

headers["If-Match"] = fmt.Sprintf("%q", etag)

So, now I have to remove double quotes before calling the Set function, like:

etag := strings.Trim(acl.ETag, "\"")
err = ts.PolicyFile().Set(context.TODO(), *acl, etag)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions