fix(licenses): fix key generation modal not passing package_id
Generic: Repo Health / Access control (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
Generic: Repo Health / Site Health (pull_request) Has been cancelled
Generic: Repo Health / Access control (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Universal: Build & Release / Promote to RC (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
PR RC Release / Build RC Release (pull_request) Has been cancelled
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report Issues (pull_request) Has been cancelled

The generate key modal's hidden package_id input was always empty
because show-modal doesn't wire data attributes to hidden inputs.
Fix: pass package_id via the form action URL query string instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-06-04 18:13:10 -05:00
parent 2f767e91cb
commit 178e8fffe2
2 changed files with 7 additions and 5 deletions
+6 -1
View File
@@ -258,7 +258,12 @@ func LicensesRegenerateMasterKey(ctx *context.Context) {
// LicensesGenerateKey handles POST to generate a new key from a package.
func LicensesGenerateKey(ctx *context.Context) {
packageID, _ := strconv.ParseInt(ctx.FormString("package_id"), 10, 64)
// Accept package_id from form body or query string (modal sets it via form action URL).
pkgIDStr := ctx.FormString("package_id")
if pkgIDStr == "" {
pkgIDStr = ctx.Req.URL.Query().Get("package_id")
}
packageID, _ := strconv.ParseInt(pkgIDStr, 10, 64)
if packageID == 0 {
ctx.Flash.Error("Invalid package")
ctx.Redirect(ctx.Repo.RepoLink + "/licenses")
+1 -4
View File
@@ -58,9 +58,7 @@
<td class="tw-text-right tw-flex tw-gap-1 tw-justify-end">
<button class="ui tiny primary button show-modal"
data-modal="#generate-key-modal"
data-modal-generate-key-modal-package-id="{{.ID}}"
data-modal-generate-key-modal-package-name="{{.Name}}"
data-modal-generate-key-modal-package-domain="{{.DomainRestriction}}"
data-modal-form.action="{{$.RepoLink}}/licenses/keys/generate?package_id={{.ID}}"
title="{{ctx.Locale.Tr "repo.licenses.generate_key"}}">
{{svg "octicon-plus" 14}}
</button>
@@ -321,7 +319,6 @@
<div class="content">
<form class="ui form" method="post" action="{{.RepoLink}}/licenses/keys/generate">
{{.CsrfTokenHtml}}
<input type="hidden" name="package_id" value="">
<div class="field">
<label>{{ctx.Locale.Tr "repo.licenses.licensee_name"}}</label>
<input name="licensee_name" placeholder="Customer name">