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

Layout: unified · split

internal/httpd/settings.go +5 −3
@@ -61,6 +61,7 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor
61 "description": submitted.Get("description"), 61 "description": submitted.Get("description"),
62 "website": submitted.Get("website"), 62 "website": submitted.Get("website"),
63 "topics": submitted.Get("topics"), 63 "topics": submitted.Get("topics"),
64 "key": submitted.Get("key"),
64 } 65 }
65 } 66 }
66 s.render(w, "settings.html", settingsPage{ 67 s.render(w, "settings.html", settingsPage{
@@ -188,10 +189,11 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store.
188 return 189 return
189 } 190 }
190 msg, ok := s.runControlStdin(u, []string{"repo", "runner", "add", repo}, body+"\n") 191 msg, ok := s.runControlStdin(u, []string{"repo", "runner", "add", repo}, body+"\n")
191 if ok { 192 if !ok {
192 msg = "" 193 s.settingsFormWith(w, r, u, msg, r.Form)
194 return
193 } 195 }
194 s.settingsRedirect(w, r, msg) 196 s.settingsRedirect(w, r, "Saved the runner.")
195 return 197 return
196 case "runner-remove": 198 case "runner-remove":
197 argv = []string{"repo", "runner", "remove", repo, v("fingerprint")} 199 argv = []string{"repo", "runner", "remove", repo, v("fingerprint")}
internal/web/templates/settings.html +1 −1
@@ -169,7 +169,7 @@
169 <input type="hidden" name="field" value="runner-add"> 169 <input type="hidden" name="field" value="runner-add">
170 <label for="runner-key">Attach a runner</label> 170 <label for="runner-key">Attach a runner</label>
171 <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> 171 <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>
173 <button type="submit" class="btn">Attach</button> 173 <button type="submit" class="btn">Attach</button>
174</form> 174</form>
175</section> 175</section>