[pkgsite] internal/api: implement query parameter parsing for api

3 views
Skip to first unread message

Ethan Lee (Gerrit)

unread,
Mar 11, 2026, 12:05:12 PM (7 days ago) Mar 11
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Ethan Lee has uploaded the change for review

Commit message

internal/api: implement query parameter parsing for api

- Introduce structs that will be used to parse query parameters.
- Implement parsing method and create relevant tests.
Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9

Change diff

diff --git a/internal/api/params.go b/internal/api/params.go
new file mode 100644
index 0000000..821f448
--- /dev/null
+++ b/internal/api/params.go
@@ -0,0 +1,135 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+ "fmt"
+ "net/url"
+ "reflect"
+ "strconv"
+ "strings"
+)
+
+// ListParams represents common pagination and filtering parameters.
+type ListParams struct {
+ Limit int `form:"limit"`
+ Token string `form:"token"`
+ Filter string `form:"filter"`
+}
+
+// PackageParams represents query parameters for /v1/package/{path}.
+type PackageParams struct {
+ Module string `form:"module"`
+ Version string `form:"version"`
+ GOOS string `form:"goos"`
+ GOARCH string `form:"goarch"`
+ Doc string `form:"doc"`
+ Examples bool `form:"examples"`
+ Licenses bool `form:"licenses"`
+}
+
+// SymbolsParams represents query parameters for /v1/symbols/{path}.
+type SymbolsParams struct {
+ Module string `form:"module"`
+ Version string `form:"version"`
+ GOOS string `form:"goos"`
+ GOARCH string `form:"goarch"`
+ ListParams
+ Examples bool `form:"examples"`
+}
+
+// ImportedByParams represents query parameters for /v1/imported-by/{path}.
+type ImportedByParams struct {
+ Module string `form:"module"`
+ Version string `form:"version"`
+ ListParams
+}
+
+// ModuleParams represents query parameters for /v1/module/{path}.
+type ModuleParams struct {
+ Version string `form:"version"`
+ Licenses bool `form:"licenses"`
+ Readme bool `form:"readme"`
+}
+
+// VersionsParams represents query parameters for /v1/versions/{path}.
+type VersionsParams struct {
+ ListParams
+}
+
+// PackagesParams represents query parameters for /v1/packages/{path}.
+type PackagesParams struct {
+ Version string `form:"version"`
+ ListParams
+}
+
+// SearchParams represents query parameters for /v1/search.
+type SearchParams struct {
+ Query string `form:"q"`
+ Symbol string `form:"symbol"`
+ ListParams
+}
+
+// VulnParams represents query parameters for /v1/vulns/{module}.
+type VulnParams struct {
+ Version string `form:"version"`
+ ListParams
+}
+
+// ParseParams populates a struct from url.Values using 'form' tags.
+// dst must be a pointer to a struct. It supports embedded structs recursively.
+func ParseParams(v url.Values, dst any) error {
+ val := reflect.ValueOf(dst)
+ if val.Kind() != reflect.Ptr || val.Elem().Kind() != reflect.Struct {
+ return fmt.Errorf("dst must be a pointer to a struct")
+ }
+ return parseValue(v, val.Elem())
+}
+
+func parseValue(v url.Values, val reflect.Value) error {
+ typ := val.Type()
+ for i := 0; i < val.NumField(); i++ {
+ field := val.Field(i)
+ structField := typ.Field(i)
+
+ if structField.Anonymous && field.Kind() == reflect.Struct {
+ if err := parseValue(v, field); err != nil {
+ return err
+ }
+ continue
+ }
+
+ tag := structField.Tag.Get("form")
+ if tag == "" {
+ continue
+ }
+
+ if !v.Has(tag) {
+ continue
+ }
+
+ rawVal := v.Get(tag)
+
+ switch field.Kind() {
+ case reflect.String:
+ field.SetString(rawVal)
+ case reflect.Int:
+ if rawVal != "" {
+ iv, err := strconv.Atoi(rawVal)
+ if err != nil {
+ return fmt.Errorf("invalid value for %s: %w", tag, err)
+ }
+ field.SetInt(int64(iv))
+ }
+ case reflect.Bool:
+ if rawVal == "" || strings.ToLower(rawVal) == "true" || rawVal == "1" || strings.ToLower(rawVal) == "on" {
+ field.SetBool(true)
+ } else {
+ field.SetBool(false)
+ }
+ }
+ }
+ return nil
+}
diff --git a/internal/api/params_test.go b/internal/api/params_test.go
new file mode 100644
index 0000000..ad5abb8
--- /dev/null
+++ b/internal/api/params_test.go
@@ -0,0 +1,92 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+ "net/url"
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+)
+
+func TestParseParams(t *testing.T) {
+ for _, test := range []struct {
+ name string
+ values url.Values
+ dst any
+ want any
+ wantErr bool
+ }{
+ {
+ name: "PackageParams",
+ values: url.Values{"module": {"m"}, "version": {"v1.0.0"}, "goos": {"linux"}, "examples": {"true"}},
+ dst: &PackageParams{},
+ want: &PackageParams{
+ Module: "m",
+ Version: "v1.0.0",
+ GOOS: "linux",
+ Examples: true,
+ },
+ },
+ {
+ name: "SymbolsParams",
+ values: url.Values{"module": {"m"}, "limit": {"50"}, "filter": {"f"}},
+ dst: &SymbolsParams{},
+ want: &SymbolsParams{
+ Module: "m",
+ ListParams: ListParams{
+ Limit: 50,
+ Filter: "f",
+ },
+ },
+ },
+ {
+ name: "SearchParams",
+ values: url.Values{"q": {"query"}, "filter": {"^net/"}, "limit": {"10"}},
+ dst: &SearchParams{},
+ want: &SearchParams{
+ Query: "query",
+ ListParams: ListParams{
+ Filter: "^net/",
+ Limit: 10,
+ },
+ },
+ },
+ {
+ name: "Boolean presence",
+ values: url.Values{"examples": {""}, "licenses": {"on"}},
+ dst: &PackageParams{},
+ want: &PackageParams{
+ Examples: true,
+ Licenses: true,
+ },
+ },
+ {
+ name: "Invalid int",
+ values: url.Values{"limit": {"not-an-int"}},
+ dst: &SymbolsParams{},
+ wantErr: true,
+ },
+ {
+ name: "Not a pointer",
+ values: url.Values{},
+ dst: PackageParams{},
+ wantErr: true,
+ },
+ } {
+ t.Run(test.name, func(t *testing.T) {
+ err := ParseParams(test.values, test.dst)
+ if (err != nil) != test.wantErr {
+ t.Fatalf("ParseParams() error = %v, wantErr %v", err, test.wantErr)
+ }
+ if test.wantErr {
+ return
+ }
+ if diff := cmp.Diff(test.want, test.dst); diff != "" {
+ t.Errorf("ParseParams() mismatch (-want +got):\n%s", diff)
+ }
+ })
+ }
+}

Change information

Files:
  • A internal/api/params.go
  • A internal/api/params_test.go
Change size: M
Delta: 2 files changed, 227 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
  • requirement is not satisfiedkokoro-CI-Passes
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: pkgsite
Gerrit-Branch: master
Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
Gerrit-Change-Number: 754240
Gerrit-PatchSet: 1
Gerrit-Owner: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Ethan Lee <etha...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ethan Lee (Gerrit)

unread,
Mar 11, 2026, 12:22:02 PM (7 days ago) Mar 11
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Ethan Lee

Ethan Lee uploaded new patchset

Ethan Lee uploaded patch set #2 to this change.
Following approvals got outdated and were removed:
  • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Lee
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
  • requirement is not satisfiedkokoro-CI-Passes
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: pkgsite
Gerrit-Branch: master
Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
Gerrit-Change-Number: 754240
Gerrit-PatchSet: 2
Gerrit-Owner: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Ethan Lee <etha...@google.com>
Gerrit-CC: kokoro <noreply...@google.com>
Gerrit-Attention: Ethan Lee <etha...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

kokoro (Gerrit)

unread,
Mar 11, 2026, 12:33:14 PM (7 days ago) Mar 11
to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
Attention needed from Ethan Lee

kokoro voted kokoro-CI+1

Kokoro presubmit build finished with status: SUCCESS
Logs at: https://source.cloud.google.com/results/invocations/6f1ef4c7-a15f-48a1-934a-3349e54b70dd

kokoro-CI+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Lee
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    • requirement is not satisfiedkokoro-CI-Passes
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pkgsite
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
    Gerrit-Change-Number: 754240
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-CC: kokoro <noreply...@google.com>
    Gerrit-Attention: Ethan Lee <etha...@google.com>
    Gerrit-Comment-Date: Wed, 11 Mar 2026 16:33:09 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    kokoro (Gerrit)

    unread,
    Mar 11, 2026, 12:50:03 PM (7 days ago) Mar 11
    to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Ethan Lee

    kokoro voted kokoro-CI+1

    Kokoro presubmit build finished with status: SUCCESS

    Related details

    Attention is currently required from:
    • Ethan Lee
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      • requirement satisfiedkokoro-CI-Passes
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pkgsite
      Gerrit-Branch: master
      Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
      Gerrit-Change-Number: 754240
      Gerrit-PatchSet: 2
      Gerrit-Owner: Ethan Lee <etha...@google.com>
      Gerrit-Reviewer: Ethan Lee <etha...@google.com>
      Gerrit-Reviewer: kokoro <noreply...@google.com>
      Gerrit-CC: kokoro <noreply...@google.com>
      Gerrit-Attention: Ethan Lee <etha...@google.com>
      Gerrit-Comment-Date: Wed, 11 Mar 2026 16:49:59 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      kokoro (Gerrit)

      unread,
      Mar 11, 2026, 4:57:22 PM (7 days ago) Mar 11
      to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
      Attention needed from Ethan Lee

      kokoro voted kokoro-CI-1

      Kokoro presubmit build finished with status: FAILURE
      Logs at: https://source.cloud.google.com/results/invocations/397f6641-46a4-4df1-a832-556cf121a0e6

      kokoro-CI-1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Ethan Lee
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        • requirement is not satisfiedkokoro-CI-Passes
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: pkgsite
        Gerrit-Branch: master
        Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
        Gerrit-Change-Number: 754240
        Gerrit-PatchSet: 3
        Gerrit-Owner: Ethan Lee <etha...@google.com>
        Gerrit-Reviewer: Ethan Lee <etha...@google.com>
        Gerrit-Reviewer: kokoro <noreply...@google.com>
        Gerrit-CC: kokoro <noreply...@google.com>
        Gerrit-Attention: Ethan Lee <etha...@google.com>
        Gerrit-Comment-Date: Wed, 11 Mar 2026 20:57:18 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Ethan Lee (Gerrit)

        unread,
        Mar 12, 2026, 11:17:58 AM (6 days ago) Mar 12
        to goph...@pubsubhelper.golang.org, Hyang-Ah Hana Kim, kokoro, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Hyang-Ah Hana Kim

        Ethan Lee voted Commit-Queue+1

        Commit-Queue+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Hyang-Ah Hana Kim
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        • requirement is not satisfiedkokoro-CI-Passes
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: pkgsite
        Gerrit-Branch: master
        Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
        Gerrit-Change-Number: 754240
        Gerrit-PatchSet: 3
        Gerrit-Owner: Ethan Lee <etha...@google.com>
        Gerrit-Reviewer: Ethan Lee <etha...@google.com>
        Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
        Gerrit-Reviewer: kokoro <noreply...@google.com>
        Gerrit-CC: kokoro <noreply...@google.com>
        Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
        Gerrit-Comment-Date: Thu, 12 Mar 2026 15:17:54 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Hyang-Ah Hana Kim (Gerrit)

        unread,
        Mar 17, 2026, 10:49:17 AM (yesterday) Mar 17
        to Ethan Lee, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, Hyang-Ah Hana Kim, kokoro, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Ethan Lee and Jonathan Amsterdam

        Hyang-Ah Hana Kim added 1 comment

        File internal/api/params.go
        Line 83, Patchset 3 (Latest):func ParseParams(v url.Values, dst any) error {
        Hyang-Ah Hana Kim . unresolved

        given that we have a predefined set of a few params to use, can we go with generics instead of reflection?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Ethan Lee
        • Jonathan Amsterdam
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement satisfiedTryBots-Pass
          • requirement is not satisfiedkokoro-CI-Passes
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: pkgsite
          Gerrit-Branch: master
          Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
          Gerrit-Change-Number: 754240
          Gerrit-PatchSet: 3
          Gerrit-Owner: Ethan Lee <etha...@google.com>
          Gerrit-Reviewer: Ethan Lee <etha...@google.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-CC: kokoro <noreply...@google.com>
          Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
          Gerrit-Attention: Ethan Lee <etha...@google.com>
          Gerrit-Comment-Date: Tue, 17 Mar 2026 14:49:13 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Jonathan Amsterdam (Gerrit)

          unread,
          Mar 17, 2026, 12:49:44 PM (yesterday) Mar 17
          to Ethan Lee, goph...@pubsubhelper.golang.org, Hyang-Ah Hana Kim, kokoro, Go LUCI, golang-co...@googlegroups.com
          Attention needed from Ethan Lee

          Jonathan Amsterdam added 4 comments

          File internal/api/params.go
          Line 14, Patchset 3 (Latest):// ListParams represents common pagination and filtering parameters.
          Jonathan Amsterdam . unresolved

          is (or are)

          Line 83, Patchset 3 (Latest):func ParseParams(v url.Values, dst any) error {
          Hyang-Ah Hana Kim . unresolved

          given that we have a predefined set of a few params to use, can we go with generics instead of reflection?

          Jonathan Amsterdam

          You need reflection to loop over the fields and get the tags.

          Line 164, Patchset 3 (Latest): if val == "" {
          Jonathan Amsterdam . unresolved

          Why is the default true? It should be false, so you don't get extra stuff unless you specifically ask for it.

          Line 170, Patchset 3 (Latest): if val == "on" {
          field.SetBool(true)
          Jonathan Amsterdam . unresolved

          why this special case? I think we should just support what strconv.ParseBool supports.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Ethan Lee
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement satisfiedTryBots-Pass
          • requirement is not satisfiedkokoro-CI-Passes
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: pkgsite
          Gerrit-Branch: master
          Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
          Gerrit-Change-Number: 754240
          Gerrit-PatchSet: 3
          Gerrit-Owner: Ethan Lee <etha...@google.com>
          Gerrit-Reviewer: Ethan Lee <etha...@google.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-CC: kokoro <noreply...@google.com>
          Gerrit-Attention: Ethan Lee <etha...@google.com>
          Gerrit-Comment-Date: Tue, 17 Mar 2026 16:49:41 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Hyang-Ah Hana Kim <hya...@gmail.com>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Ethan Lee (Gerrit)

          unread,
          Mar 17, 2026, 5:15:29 PM (21 hours ago) Mar 17
          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from Ethan Lee

          Ethan Lee uploaded new patchset

          Ethan Lee uploaded patch set #4 to this change.
          Following approvals got outdated and were removed:
          • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
          • kokoro-CI-Passes: kokoro-CI-1 by kokoro
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Ethan Lee
          Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            • requirement is not satisfiedkokoro-CI-Passes
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: newpatchset
            Gerrit-Project: pkgsite
            Gerrit-Branch: master
            Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
            Gerrit-Change-Number: 754240
            Gerrit-PatchSet: 4
            unsatisfied_requirement
            open
            diffy

            Ethan Lee (Gerrit)

            unread,
            Mar 17, 2026, 5:15:42 PM (21 hours ago) Mar 17
            to goph...@pubsubhelper.golang.org, Jonathan Amsterdam, Hyang-Ah Hana Kim, kokoro, Go LUCI, golang-co...@googlegroups.com
            Attention needed from Hyang-Ah Hana Kim and Jonathan Amsterdam

            Ethan Lee added 4 comments

            File internal/api/params.go
            Line 14, Patchset 3:// ListParams represents common pagination and filtering parameters.
            Jonathan Amsterdam . resolved

            is (or are)

            Ethan Lee

            Done

            Line 83, Patchset 3:func ParseParams(v url.Values, dst any) error {
            Hyang-Ah Hana Kim . unresolved

            given that we have a predefined set of a few params to use, can we go with generics instead of reflection?

            Jonathan Amsterdam

            You need reflection to loop over the fields and get the tags.

            Ethan Lee

            Yes, but I think it depends on if we want a dynamic approach to support more param types in the future. Using reflection means that any struct with form tags will work. However, given that it seems that the query parameters for API will likely be stable, it's probably best to use generics to accommodate the predefined set of structs. We can avoid the overhead of reflection which would be incurred on every API call.

            Line 164, Patchset 3: if val == "" {
            Jonathan Amsterdam . resolved

            Why is the default true? It should be false, so you don't get extra stuff unless you specifically ask for it.

            Ethan Lee

            Good point, addressed this in the change with generics.

            Line 170, Patchset 3: if val == "on" {
            field.SetBool(true)
            Jonathan Amsterdam . resolved

            why this special case? I think we should just support what strconv.ParseBool supports.

            Ethan Lee

            Addressed this in the change with generics.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Hyang-Ah Hana Kim
            • Jonathan Amsterdam
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            • requirement is not satisfiedkokoro-CI-Passes
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: pkgsite
            Gerrit-Branch: master
            Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
            Gerrit-Change-Number: 754240
            Gerrit-PatchSet: 4
            Gerrit-Owner: Ethan Lee <etha...@google.com>
            Gerrit-Reviewer: Ethan Lee <etha...@google.com>
            Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
            Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
            Gerrit-Reviewer: kokoro <noreply...@google.com>
            Gerrit-CC: kokoro <noreply...@google.com>
            Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
            Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
            Gerrit-Comment-Date: Tue, 17 Mar 2026 21:15:38 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Hyang-Ah Hana Kim <hya...@gmail.com>
            Comment-In-Reply-To: Jonathan Amsterdam <j...@google.com>
            unsatisfied_requirement
            open
            diffy

            Ethan Lee (Gerrit)

            unread,
            Mar 17, 2026, 5:22:08 PM (21 hours ago) Mar 17
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
            Attention needed from Ethan Lee, Hyang-Ah Hana Kim and Jonathan Amsterdam

            Ethan Lee uploaded new patchset

            Ethan Lee uploaded patch set #5 to this change.
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Ethan Lee
            • Hyang-Ah Hana Kim
            • Jonathan Amsterdam
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            • requirement is not satisfiedkokoro-CI-Passes
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: newpatchset
            Gerrit-Project: pkgsite
            Gerrit-Branch: master
            Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
            Gerrit-Change-Number: 754240
            Gerrit-PatchSet: 5
            Gerrit-Owner: Ethan Lee <etha...@google.com>
            Gerrit-Reviewer: Ethan Lee <etha...@google.com>
            Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
            Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
            Gerrit-Reviewer: kokoro <noreply...@google.com>
            Gerrit-CC: kokoro <noreply...@google.com>
            Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
            Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
            Gerrit-Attention: Ethan Lee <etha...@google.com>
            unsatisfied_requirement
            open
            diffy

            kokoro (Gerrit)

            unread,
            Mar 17, 2026, 5:40:26 PM (20 hours ago) Mar 17
            to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, Jonathan Amsterdam, Hyang-Ah Hana Kim, golang-co...@googlegroups.com
            Attention needed from Ethan Lee, Hyang-Ah Hana Kim and Jonathan Amsterdam

            kokoro voted kokoro-CI+1

            Kokoro presubmit build finished with status: SUCCESS
            Logs at: https://source.cloud.google.com/results/invocations/2155f6ed-f9ba-4a32-b771-f31bca0b9ac3

            kokoro-CI+1
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Ethan Lee
            • Hyang-Ah Hana Kim
            • Jonathan Amsterdam
            Submit Requirements:
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement is not satisfiedReview-Enforcement
              • requirement satisfiedTryBots-Pass
              • requirement is not satisfiedkokoro-CI-Passes
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: pkgsite
              Gerrit-Branch: master
              Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
              Gerrit-Change-Number: 754240
              Gerrit-PatchSet: 4
              Gerrit-Owner: Ethan Lee <etha...@google.com>
              Gerrit-Reviewer: Ethan Lee <etha...@google.com>
              Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
              Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
              Gerrit-Reviewer: kokoro <noreply...@google.com>
              Gerrit-CC: kokoro <noreply...@google.com>
              Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
              Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
              Gerrit-Attention: Ethan Lee <etha...@google.com>
              Gerrit-Comment-Date: Tue, 17 Mar 2026 21:40:22 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              kokoro (Gerrit)

              unread,
              Mar 17, 2026, 5:40:48 PM (20 hours ago) Mar 17
              to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, Jonathan Amsterdam, Hyang-Ah Hana Kim, golang-co...@googlegroups.com
              Attention needed from Ethan Lee, Hyang-Ah Hana Kim and Jonathan Amsterdam

              kokoro voted kokoro-CI-1

              Kokoro presubmit build finished with status: FAILURE
              Logs at: https://source.cloud.google.com/results/invocations/7e4f7b24-ee3b-4372-b963-171f77c37fac

              kokoro-CI-1
              Open in Gerrit

              Related details

              Attention is currently required from:
              • Ethan Lee
              • Hyang-Ah Hana Kim
              • Jonathan Amsterdam
              Submit Requirements:
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement is not satisfiedReview-Enforcement
              • requirement satisfiedTryBots-Pass
              • requirement is not satisfiedkokoro-CI-Passes
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: pkgsite
              Gerrit-Branch: master
              Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
              Gerrit-Change-Number: 754240
              Gerrit-PatchSet: 5
              Gerrit-Owner: Ethan Lee <etha...@google.com>
              Gerrit-Reviewer: Ethan Lee <etha...@google.com>
              Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
              Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
              Gerrit-Reviewer: kokoro <noreply...@google.com>
              Gerrit-CC: kokoro <noreply...@google.com>
              Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
              Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
              Gerrit-Attention: Ethan Lee <etha...@google.com>
              Gerrit-Comment-Date: Tue, 17 Mar 2026 21:40:43 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Jonathan Amsterdam (Gerrit)

              unread,
              8:57 AM (5 hours ago) 8:57 AM
              to Ethan Lee, goph...@pubsubhelper.golang.org, kokoro, Go LUCI, Hyang-Ah Hana Kim, golang-co...@googlegroups.com
              Attention needed from Ethan Lee and Hyang-Ah Hana Kim

              Jonathan Amsterdam added 2 comments

              File internal/api/params.go
              Line 82, Patchset 5 (Latest): var res T
              Jonathan Amsterdam . unresolved

              I don't think you're really using generics here. This is just a type switch over a finite list of types. A more natural way to express this in Go is to add a Parse method to each struct.

              Line 83, Patchset 3:func ParseParams(v url.Values, dst any) error {
              Hyang-Ah Hana Kim . resolved

              given that we have a predefined set of a few params to use, can we go with generics instead of reflection?

              Jonathan Amsterdam

              You need reflection to loop over the fields and get the tags.

              Ethan Lee

              Yes, but I think it depends on if we want a dynamic approach to support more param types in the future. Using reflection means that any struct with form tags will work. However, given that it seems that the query parameters for API will likely be stable, it's probably best to use generics to accommodate the predefined set of structs. We can avoid the overhead of reflection which would be incurred on every API call.

              Jonathan Amsterdam

              Acknowledged

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Ethan Lee
              • Hyang-Ah Hana Kim
              Submit Requirements:
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement is not satisfiedReview-Enforcement
              • requirement satisfiedTryBots-Pass
              • requirement is not satisfiedkokoro-CI-Passes
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: pkgsite
              Gerrit-Branch: master
              Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
              Gerrit-Change-Number: 754240
              Gerrit-PatchSet: 5
              Gerrit-Owner: Ethan Lee <etha...@google.com>
              Gerrit-Reviewer: Ethan Lee <etha...@google.com>
              Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
              Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
              Gerrit-Reviewer: kokoro <noreply...@google.com>
              Gerrit-CC: kokoro <noreply...@google.com>
              Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
              Gerrit-Attention: Ethan Lee <etha...@google.com>
              Gerrit-Comment-Date: Wed, 18 Mar 2026 12:57:16 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              Comment-In-Reply-To: Hyang-Ah Hana Kim <hya...@gmail.com>
              Comment-In-Reply-To: Jonathan Amsterdam <j...@google.com>
              Comment-In-Reply-To: Ethan Lee <etha...@google.com>
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Ethan Lee (Gerrit)

              unread,
              11:46 AM (2 hours ago) 11:46 AM
              to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
              Attention needed from Ethan Lee and Hyang-Ah Hana Kim

              Ethan Lee uploaded new patchset

              Ethan Lee uploaded patch set #6 to this change.
              Following approvals got outdated and were removed:
              • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
              • kokoro-CI-Passes: kokoro-CI-1 by kokoro

              Related details

              Attention is currently required from:
              • Ethan Lee
              • Hyang-Ah Hana Kim
              Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                • requirement is not satisfiedkokoro-CI-Passes
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: newpatchset
                Gerrit-Project: pkgsite
                Gerrit-Branch: master
                Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
                Gerrit-Change-Number: 754240
                Gerrit-PatchSet: 6
                unsatisfied_requirement
                open
                diffy

                Ethan Lee (Gerrit)

                unread,
                11:46 AM (2 hours ago) 11:46 AM
                to goph...@pubsubhelper.golang.org, kokoro, Go LUCI, Jonathan Amsterdam, Hyang-Ah Hana Kim, golang-co...@googlegroups.com
                Attention needed from Hyang-Ah Hana Kim and Jonathan Amsterdam

                Ethan Lee added 1 comment

                File internal/api/params.go
                Line 82, Patchset 5: var res T
                Jonathan Amsterdam . resolved

                I don't think you're really using generics here. This is just a type switch over a finite list of types. A more natural way to express this in Go is to add a Parse method to each struct.

                Ethan Lee

                Discussed offline, let's go with the previous implementation given that it's more extensible and thus easier to maintain in the future.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Hyang-Ah Hana Kim
                • Jonathan Amsterdam
                Submit Requirements:
                  • requirement is not satisfiedCode-Review
                  • requirement satisfiedNo-Unresolved-Comments
                  • requirement is not satisfiedReview-Enforcement
                  • requirement is not satisfiedTryBots-Pass
                  • requirement is not satisfiedkokoro-CI-Passes
                  Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                  Gerrit-MessageType: comment
                  Gerrit-Project: pkgsite
                  Gerrit-Branch: master
                  Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
                  Gerrit-Change-Number: 754240
                  Gerrit-PatchSet: 6
                  Gerrit-Owner: Ethan Lee <etha...@google.com>
                  Gerrit-Reviewer: Ethan Lee <etha...@google.com>
                  Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
                  Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
                  Gerrit-Reviewer: kokoro <noreply...@google.com>
                  Gerrit-CC: kokoro <noreply...@google.com>
                  Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
                  Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
                  Gerrit-Comment-Date: Wed, 18 Mar 2026 15:46:25 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  Comment-In-Reply-To: Jonathan Amsterdam <j...@google.com>
                  unsatisfied_requirement
                  satisfied_requirement
                  open
                  diffy

                  kokoro (Gerrit)

                  unread,
                  12:11 PM (2 hours ago) 12:11 PM
                  to Ethan Lee, goph...@pubsubhelper.golang.org, Go LUCI, Jonathan Amsterdam, Hyang-Ah Hana Kim, golang-co...@googlegroups.com
                  Attention needed from Ethan Lee, Hyang-Ah Hana Kim and Jonathan Amsterdam

                  kokoro voted kokoro-CI+1

                  Kokoro presubmit build finished with status: SUCCESS
                  Logs at: https://source.cloud.google.com/results/invocations/52cc468c-7dd9-48be-8724-b0b5956648b7

                  kokoro-CI+1
                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Ethan Lee
                  • Hyang-Ah Hana Kim
                  • Jonathan Amsterdam
                    Submit Requirements:
                      • requirement is not satisfiedCode-Review
                      • requirement satisfiedNo-Unresolved-Comments
                      • requirement is not satisfiedReview-Enforcement
                      • requirement satisfiedTryBots-Pass
                      • requirement satisfiedkokoro-CI-Passes
                      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                      Gerrit-MessageType: comment
                      Gerrit-Project: pkgsite
                      Gerrit-Branch: master
                      Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
                      Gerrit-Change-Number: 754240
                      Gerrit-PatchSet: 6
                      Gerrit-Owner: Ethan Lee <etha...@google.com>
                      Gerrit-Reviewer: Ethan Lee <etha...@google.com>
                      Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
                      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
                      Gerrit-Reviewer: kokoro <noreply...@google.com>
                      Gerrit-CC: kokoro <noreply...@google.com>
                      Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
                      Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
                      Gerrit-Attention: Ethan Lee <etha...@google.com>
                      Gerrit-Comment-Date: Wed, 18 Mar 2026 16:11:20 +0000
                      Gerrit-HasComments: No
                      Gerrit-Has-Labels: Yes
                      unsatisfied_requirement
                      satisfied_requirement
                      open
                      diffy

                      Jonathan Amsterdam (Gerrit)

                      unread,
                      1:11 PM (1 hour ago) 1:11 PM
                      to Ethan Lee, goph...@pubsubhelper.golang.org, kokoro, Go LUCI, Hyang-Ah Hana Kim, golang-co...@googlegroups.com
                      Attention needed from Ethan Lee and Hyang-Ah Hana Kim

                      Jonathan Amsterdam voted Code-Review+2

                      Code-Review+2
                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Ethan Lee
                      • Hyang-Ah Hana Kim
                      Submit Requirements:
                      • requirement satisfiedCode-Review
                      • requirement satisfiedNo-Unresolved-Comments
                      • requirement satisfiedReview-Enforcement
                      • requirement satisfiedTryBots-Pass
                      • requirement satisfiedkokoro-CI-Passes
                      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                      Gerrit-MessageType: comment
                      Gerrit-Project: pkgsite
                      Gerrit-Branch: master
                      Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
                      Gerrit-Change-Number: 754240
                      Gerrit-PatchSet: 6
                      Gerrit-Owner: Ethan Lee <etha...@google.com>
                      Gerrit-Reviewer: Ethan Lee <etha...@google.com>
                      Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
                      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
                      Gerrit-Reviewer: kokoro <noreply...@google.com>
                      Gerrit-CC: kokoro <noreply...@google.com>
                      Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
                      Gerrit-Attention: Ethan Lee <etha...@google.com>
                      Gerrit-Comment-Date: Wed, 18 Mar 2026 17:11:38 +0000
                      Gerrit-HasComments: No
                      Gerrit-Has-Labels: Yes
                      satisfied_requirement
                      open
                      diffy

                      Gopher Robot (Gerrit)

                      unread,
                      1:11 PM (1 hour ago) 1:11 PM
                      to Ethan Lee, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Jonathan Amsterdam, kokoro, Go LUCI, Hyang-Ah Hana Kim, golang-co...@googlegroups.com

                      Gopher Robot submitted the change

                      Change information

                      Commit message:
                      internal/api: implement query parameter parsing for api

                      - Introduce structs that will be used to parse query parameters.
                      - Implement parsing method and create relevant tests.
                      Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
                      Auto-Submit: Ethan Lee <etha...@google.com>
                      Reviewed-by: Jonathan Amsterdam <j...@google.com>
                      kokoro-CI: kokoro <noreply...@google.com>
                      Files:
                      • A internal/api/params.go
                      • A internal/api/params_test.go
                      Change size: L
                      Delta: 2 files changed, 376 insertions(+), 0 deletions(-)
                      Branch: refs/heads/master
                      Submit Requirements:
                      • requirement satisfiedCode-Review: +2 by Jonathan Amsterdam
                      • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
                      • requirement satisfiedkokoro-CI-Passes: kokoro-CI+1 by kokoro
                      Open in Gerrit
                      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                      Gerrit-MessageType: merged
                      Gerrit-Project: pkgsite
                      Gerrit-Branch: master
                      Gerrit-Change-Id: Ib54a57a7eb8d2dbaab0edf705a6cb9e5bc8288a9
                      Gerrit-Change-Number: 754240
                      Gerrit-PatchSet: 7
                      Gerrit-Owner: Ethan Lee <etha...@google.com>
                      Gerrit-Reviewer: Ethan Lee <etha...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      open
                      diffy
                      satisfied_requirement
                      Reply all
                      Reply to author
                      Forward
                      0 new messages