Commit 3f9f6ba925

3f9f6ba9253df8d89b69585b9f42d28e9b5fde78

parent: 534f5f1168

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-18 04:11 UTC

httpd: runner attach reports failure without dropping the key

A rejected attach redirected to a flash message, discarding the pasted
key: the visitor retyped it. runner-add now renders the settings form
directly on failure, with the key preserved in Submitted, and states
success explicitly as "Saved the runner." instead of relying on an
empty message.

Ref #221
internal/httpd/settings.go +5 −3
@@ -61,6 +61,7 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor
6161 "description": submitted.Get("description"),
6262 "website": submitted.Get("website"),
6363 "topics": submitted.Get("topics"),
64 "key": submitted.Get("key"),
6465 }
6566 }
6667 s.render(w, "settings.html", settingsPage{
@@ -188,10 +189,11 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store.
188189 return
189190 }
190191 msg, ok := s.runControlStdin(u, []string{"repo", "runner", "add", repo}, body+"\n")
191 if ok {
192 msg = ""
192 if !ok {
193 s.settingsFormWith(w, r, u, msg, r.Form)
194 return
193195 }
194 s.settingsRedirect(w, r, msg)
196 s.settingsRedirect(w, r, "Saved the runner.")
195197 return
196198 case "runner-remove":
197199 argv = []string{"repo", "runner", "remove", repo, v("fingerprint")}
internal/web/templates/settings.html +1 −1
@@ -169,7 +169,7 @@
169169 <input type="hidden" name="field" value="runner-add">
170170 <label for="runner-key">Attach a runner</label>
171171 <p class="hint">Install <code>gitbay-runner</code>, run <code>gitbay-runner init</code>, and paste the key it prints. The runner builds your commits with the repository's secrets; merge requests from forks wait unless it runs with <code>-untrusted</code>.</p>
172 <textarea id="runner-key" name="key" rows="3" placeholder="ssh-ed25519 AAAA… (from gitbay-runner init)"></textarea>
172 <textarea id="runner-key" name="key" rows="3" placeholder="ssh-ed25519 AAAA… (from gitbay-runner init)">{{index .Submitted "key"}}</textarea>
173173 <button type="submit" class="btn">Attach</button>
174174</form>
175175</section>