Repository navigation
✨ knowledge: edit an existing git source (PUT /api/knowledge/git-sources) - #17596
Conversation
…ces)
A fat-fingered URL, name, subpath, branch or layer on a knowledge git
source could only be corrected by Remove + re-add, which throws away the
clone and re-indexes even when only the display name was wrong.
Add PUT /api/knowledge/git-sources, owner-gated like connect/disconnect,
taking {url, subpath} as the identity plus the new fields. A name/layer
change rewrites the live source and its config entry in place without
touching the clone; a url/branch/subpath change swaps in a fresh clone in
the same request, keeping the old source if the new clone fails. Either
way one knowledge_git_source_update audit row is written. The dashboard
gets an Edit button per row that loads it into the Add Git Source form
(Save / Cancel).
The inline required-field helper from #17589 only landed on v5, so it is
carried here unchanged to let the edit form reuse it on v6.
Closes #17588
Part of #17583
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: pushed 919acb1 — docs-only, applies the reviewer-2 follow-up on 4dcc6fb (the YAML example comment at knowledge-curator.md:33 no longer calls 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from Read the tree at What I verified:
One pre-existing limitation this feature makes a little easier to hit (not a defect of this PR, no action required):
I have not approved or merged anything; a maintainer's signature is still needed. stage 080-awaiting-merge-admission → 070-fixing: check-cancelled Review findings from Read the full backend diff against the v6 tree ( What I verified
Low-severity notes (not blockers)
The PR body matches the diff; the carried-over Review findings from Style/maintainability review (head 919acb1) — no in-scope blocker; two advisory notes and one adjacent bug for backlog.
Advisory: audit event Review findings from Correctness review (head
Out of scope (pre-existing, noting for backlog): for a URL/subpath change whose new slug directory already exists on disk (old clones are never deleted), Tests for metadata-vs-reclone, staged promotion, mid-clone disconnect and blank-branch resolution are present and look adequate. Review findings from Style review at head One small gap between the body and the diff, outside the #17588 contract (belongs to the #17583 addendum):
Otherwise: shared |
There was a problem hiding this comment.
Read the diff against the v6 tree and the callers. This looks correct to me.
What I verified:
knowledge/api.goReplaceGitSourcefollowsConnectGitSourceexactly (validate → RLock conflict scan →newGitSourceForConnect→initGitSourceForConnect→ swap underLock→go startGitSourceSyncLoopForConnect), so the test seams keep working and the old source stays ink.gitSourcesuntil the new clone has succeeded.gitsource.gowithConfigshares the*FileStorepointer with the originalGitSource.Sync()(gitsource.go:171-177) reindexes that same store in place, so the sync loop still running on the old pointer keeps the renamed source's index fresh. Layer is read live viags.Config().Layer(api.go:959,api.go:1012), so a layer-only edit takes effect without re-indexing.dashboard/api_knowledge.gohandleGitSourcesUpdateapplies the same name/branch/subpath/URL checks ashandleGitSourcesConnect(api_knowledge.go:1167-1181) and is owner-gated. Thehive.yamlrewrite drops any stale entry that already carries the new{url, subpath}, which is the right call sinceReplaceGitSourcehas already refused the case where a live source owns it.knowledge.jssends{url, subpath, new_url, new_subpath, name, branch, layer}on Save andPOSTon Add; the submit label/reset go throughkbGitSourceSubmitLabel().
One note, not a defect in this PR: on a URL/subpath move (sameIdentity == false) the old clone directory is left on disk and the old source's StartSyncLoop goroutine keeps pulling it until s.deps.Ctx is cancelled. DisconnectGitSource (api.go:1121-1140) has the same behaviour today, so this PR is consistent with the existing pattern — just flagging it in case a follow-up wants a per-source cancel.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Mutation testing (advisory)Head No surviving mutants reported in the packages that finished. ⏱ Time budget (1020s) exhausted: 2 of 2 changed package(s) were not fully mutated, so this report is partial:
Advisory only; this job never blocks the PR (#17349). |
|
Test gap: In the Two cheap additions would pin the behaviour the PR actually promises:
Not blocking on its own; flagging because the test comment makes a stronger claim than the assertions verify, and the restore branch is the only part of this change with no coverage at all. 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
docs-currency (read at head 75a506c)
Docs cover the new endpoint well (OpenAPI, route tables, contribute page, curator guide, changelog). Two advisory accuracy points, neither blocking:
-
"Old source keeps serving if the new clone fails" is unconditional in the docs but conditional in the code.
dashboard/openapi.json:14586andsrc/docs/knowledge-curator.md:132-136say the old source stays in place on a failed edit. That holds for a url/subpath move, but for a branch-only editReplaceGitSourcefirst deletes the shared clone directory (src/pkg/knowledge/api.go:1201) and on failure only attempts a re-clone (api.go:1207,restoreGitSourceapi.go:1222-1228); if that re-clone also fails the error is just logged (api.go:1227) and the operator is left with a source whose clone is gone. Suggest qualifying the sentence in both places (e.g. "a branch-only edit clears the clone first; the original is re-cloned if the new clone fails, and must be re-added if that also fails") and the500description. -
Stale source citation on the line this PR edited.
src/docs/knowledge-curator.md:120-121now readsGET/POST/PUT/DELETE … (pkg/dashboard/api_knowledge.go:980-986,988-1070,1072-1114)but at head the handlers are atapi_knowledge.go:1131(List),:1139(Connect),:1223(Disconnect),:1273(Update) — the new PUT handler is not covered by the cited range. Since the PR refreshed the shiftedapi.gocitations elsewhere, this one should be refreshed too.
Out of scope (pre-existing): knowledge-curator.md:45 still says name is "the key used to look up/remove the source via the API", which the new bullet at :132 (identity = url+subpath) now directly contradicts.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
Review follow-ups (below
|
There was a problem hiding this comment.
Read the v6 tree at merge-base plus the diff. The core swap/replace logic looks correct to me; one low open question below, nothing I would block on.
What I verified:
StopSyncLoopactually reaches every source. Both producers ofk.gitSources— startup (cmd/hive/main.go:3237) and the dashboard POST (api_knowledge.go:1194) — go throughConnectGitSource, which now binds the per-source cancel instartGitSourceSyncbefore the goroutine starts. So a replaced/disconnected source's loop really stops; there is no path that leaves an unbound loop pulling a detached store.withConfigsnapshot is safe. OnlyInitwritesg.store/g.ready(gitsource.go:103-104);Synconly readsg.storeunderRLock. The copy sharing the store pointer andstopSynctherefore cannot go stale on a name/layer edit.- Same-identity branch change.
gitSourceStagingDiryields an empty sibling,ensureClonedsees!isGitRepoand clones into it,promoteStagedClonerenames aside → in → deletes, and restores the old clone if the second rename fails.promoteruns underk.mujust before publish, so a concurrent Remove returnsErrGitSourceNotFoundinstead of resurrecting the source.FileStore.Relocaterewritespages[*].Pathwith a..guard. The conflict scan can't false-positive on same identity because theoldmatch is tested first. - Handler parity with POST.
requireOwnerRole,ValidateGitSourceURLContext, the sharedvalidateGitSourceFields;Layeris unvalidated on PUT exactly as it is on POST (api_knowledge.go:1192), so no new gap. Route registered atapi.goasPUT /api/knowledge/git-sources; the contribute page%scount went 21→22 to match the added block. - Startup blank-branch resolution is not a regression for offline boots. Previously
ensureCloned→gitSourcePullalready failedInitwithout network, so moving the failure tols-remotechanges the message, not the outcome.
Open question (low): cloneDir is keyed by gitSourceSlug(url, subpath) only (gitsource.go:58-59), and ensureCloned reuses any existing clone without checking its branch. A pre-existing hive.yaml entry with blank branch that was cloned as main under the old default will, after upgrade, resolve to the remote's real default (say develop) and report that branch while the reused clone still tracks main. This mismatch is pre-existing in spirit (the reuse path never honoured Branch), and the new same-identity Replace path handles it correctly via staging — so I'd note it rather than fix it here. Worth a follow-up issue if the startup path should re-clone when the recorded branch differs from the clone's.
Body matches the diff, including the stated byte-identical carry-overs of #17589/#17614 from v5 (the three changelog fragments are explained by that). Closes #17588 / Closes #17583 are appropriate. CI was still in progress at review time.
— hive reviewer (claude-fable-5.1)
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
…clone, lock GitSources() Review follow-ups on the git-source edit endpoint: - swapGitSource now cancels the old source's sync loop and waits for it to return before promote() renames the clone aside, so a `git pull` in flight can no longer keep writing into the moved-aside directory and leave a *.replaced-* tree behind. If promote fails the old source stays published and its loop is restarted. bindSyncContext hands out a done channel that startGitSourceSync closes when the loop goroutine exits; StopSyncLoop waits on it. - KnowledgeAPI.GitSources() reads k.gitSources under k.mu.RLock, since UpdateGitSourceMetadata and swapGitSource replace slice elements under the lock. - Reword the handler comment: the handler resolves a blank branch itself before deciding whether to re-clone. - kbImportDocFromModal looks up its busy button by data-action, matching how the button is rendered; regenerate static/index.html. Hive-Fix-Attempt: 3/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read the diff against the v6 tree (src/pkg/knowledge/{api,gitsource,filestore}.go, src/pkg/dashboard/api_knowledge.go) and the callers. Looks correct to me; nothing blocking.
What I verified:
- Old source keeps serving until the new one is indexed.
ReplaceGitSourcerunsinitGitSourceForConnect(clone +NewFileStore) beforeswapGitSourcetakesk.mu(src/pkg/knowledge/api.go), andswapGitSourcereturnsErrGitSourceNotFoundwithout publishing if the identity is gone — so a Remove during the clone wins, as the body says.TestReplaceGitSourceDoesNotResurrectRemovedSourcecovers it. - Same-identity branch edit cannot collide with the live clone.
NewGitSourcederivescloneDirfromgitSourceSlug(url, subpath)only (gitsource.go:62-63), so url+subpath unchanged really does mean the same directory; cloning into theos.MkdirTempsibling and renaming overfinalDironly afterStopSyncLoop()has returned (swapGitSource) means nogit pullis writing into the directory being renamed aside.promoteStagedClonerestores the old clone if the second rename fails, anddefer os.RemoveAll(staging)is a no-op after a successful promotion because the path no longer exists. - Sync loops run on the server context, not the request. The handler passes
s.deps.CtxtoReplaceGitSource, matching the existingConnectGitSourcecall;r.Context()is only used for URL validation andls-remote. - Metadata edit shares the loop correctly.
withConfigcopiesstopSync/syncDone, soStopSyncLoop()on the renamed copy cancels the goroutine that still holds the original*GitSource.Sync()doesn't mutateready, so the copied snapshot stays accurate. - Validation parity.
validateGitSourceFieldsis the same three checks Connect had inline; Update isrequireOwnerRole-gated like Connect/Disconnect. Neither Connect nor Update validateslayer— pre-existing, not introduced here.
One cosmetic note (not a defect): after a name-only edit the still-running sync goroutine holds the original *GitSource, so StartSyncLoop's warn/debug lines (gitsource.go:300-305) keep logging the old name until the source is replaced or the server restarts. Harmless; mentioning so nobody chases it as a bug later.
Body matches the diff on every claim I checked (identity key, owner gating, single audit row, 404-on-removed, stale selector fix at knowledge.js:2162, blank branch resolved server-side). I have not verified byte-identity of the carried-over v5 fragments (#17589/#17614); the next v5→v6 top-up will surface any drift.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against the v6 tree (src/pkg/knowledge/{api,gitsource,filestore}.go, src/pkg/dashboard/api_knowledge.go, static-src/js/knowledge.js) plus the callers. The core mechanism looks correct to me:
- Startup sources go through
ConnectGitSource(src/cmd/hive/main.go:3237), so every published source has a boundstopSync/syncDone;StopSyncLoopis not a no-op for config-loaded sources, andSync→gitPullWithEnvusesexec.CommandContext, so cancellation returns promptly rather than waiting out the 30s pull timeout whilek.muis held. - Same-identity (branch-only) edit:
relocate(staging)beforeInitmakesensureClonedclone into the empty temp dir;promoteStagedClonerenames the old clone aside, moves staging in, and puts the old one back on failure (api.go:1266-1286).FileStore.Relocaterewrites page paths so the index survives the rename. Old clone is never touched on a failed clone — matches the PR body. swapGitSourcere-matches the identity under the write lock, so a Remove that raced the clone wins with 404 (api.go:1315-1332), andTestReplaceGitSourceDoesNotResurrectRemovedSourcecovers it.withConfigreturns a copy sharing store/loop/cancel so a name/layer edit never mutates a struct the loop goroutine is reading; the loop goroutine's log lines keep the oldconfig.Name, which is cosmetic.- PUT handler is owner-gated like POST/DELETE, shares
validateGitSourceFields, andReplaceGitSourcerevalidates the URL (SSRF guard) even though the handler already did.
One narrow, verified race (low):
ReplaceGitSource conflict check is not re-run at publish time — src/pkg/knowledge/api.go:1217 checks ErrGitSourceConflict under RLock, releases it, then clones (up to 120s). swapGitSource (api.go:1315-1332) only re-matches the old identity, not the new one. If a POST /api/knowledge/git-sources for the new {url, subpath} completes during that window, the swap publishes a second source with the same identity. Consequence: DisconnectGitSource (api.go:1149) drops both from the slice but removed holds only the last match, so removed.StopSyncLoop() at :1158 stops one loop and the other keeps pulling for the server's lifetime. Fix is small: re-scan for config.URL/config.Subpath inside swapGitSource and return ErrGitSourceConflict (the defer os.RemoveAll(staging) already cleans up the same-identity case; the new-identity clone dir would be orphaned, same as today's Remove). Not a blocker — it needs two operators editing toward the same target inside one clone window — but worth a follow-up.
Body vs diff: the stated behaviours (metadata-only edits don't re-clone; url/branch/subpath re-clone in one request; old source serves until new is ready; Remove wins; one audit row; v5 kbFieldError carry-over) are all present in the diff. Tests cover metadata-vs-reclone, failure-keeps-original, staged promotion, blank-branch resolution and the removed-during-clone case. Docs (openapi, api-reference tables, contribute page, knowledge-curator.md) and the changelog fragment are updated.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Docs-currency review of head 1. 2. Same table contradicts the new PUT section on identity — 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Smallest fix, test-side only — register the disconnect after the stub-restore cleanup so LIFO runs it first: k := &KnowledgeAPI{logger: slog.Default()}
t.Cleanup(func() { _ = k.DisconnectGitSource("https://github.com/org/repo", "") })
err := k.ConnectGitSource(context.Background(), GitSourceConfig{Name: "n", URL: "https://github.com/org/repo", Layer: LayerProject})(Alternatively capture Baseline note: (The preceding quality comment — a docs-currency note against head 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
startGitSourceSync read startGitSourceSyncLoopForConnect inside the new goroutine, after ConnectGitSource had already returned. Tests that stub the hook and restore it in t.Cleanup therefore raced the read, and the race detector failed pkg/knowledge. Capture the hook on the caller's goroutine so the restore can never overlap the read. No production behaviour change: the hook is never reassigned outside tests. Hive-Fix-Attempt: 4/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Correctness re-review at b54ff7b (delta since 9f49eb5: src/pkg/knowledge/api.go only).
Fixed: the sync-loop hook data race — startGitSourceSync now reads startGitSourceSyncLoopForConnect on the caller's goroutine before spawning (src/pkg/knowledge/api.go:1124-1127). ✅
Still present: same-slug URL edit with branch change serves the old branch.
ReplaceGitSource decides whether to clone into a staging dir by textual identity, sameIdentity := config.URL == oldURL && config.Subpath == oldSubpath (api.go:1210). But the clone directory comes from gitSourceSlug, which strips https:///http:// and a trailing .git (gitsource.go:680-686). So editing https://github.com/a/b → https://github.com/a/b.git (or http→https) with a new branch yields sameIdentity == false, no staging, and finalDir equal to the old source's clone dir. ensureCloned then sees isGitRepo(g.cloneDir) and runs gitSourcePull on the existing checkout (gitsource.go:312-318) — the --branch clone at :327 never runs. The new source reports the new branch in Info() but indexes the old branch's files, and its sync loop keeps pulling the old branch.
Fix: key the staging decision on the clone path, not the textual identity — e.g. useStaging := finalDir == old.CloneDir() after gs := newGitSourceForConnect(...) at api.go:1236-1237, and use it in place of sameIdentity for the staging/promote branches. The conflict check at :1216-1218 can stay on textual identity. A table-test case with URL differing only by .git + a branch change would pin this.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
… clone dir ReplaceGitSource decided whether to stage by comparing URL+subpath, but the clone directory is keyed by gitSourceSlug, which strips the scheme and a ".git" suffix. A URL edit that only added ".git" therefore skipped staging, ensureCloned git-pulled the old checkout, and the configured branch was never applied while config and the API reported the new one. Branch on gs.CloneDir() == old.CloneDir() instead and pin it with a test. Docs: knowledge-curator.md now says a blank branch resolves the remote default for hive.yaml and the API alike (main only without a HEAD symref, connect fails if ls-remote errors), and refreshes the stale api_knowledge.go line citations in the rewritten sentences. Hive-Fix-Attempt: 5/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read the diff against src/pkg/knowledge and src/pkg/dashboard at the merge-base (859f6a3), plus the callers of the new helpers. The replace path is sound; two low-severity notes on the metadata-only path, nothing blocking.
What I verified as correct
ReplaceGitSource(src/pkg/knowledge/api.go:1203-1275): the old source keeps serving untilInitsucceeds; the staging clone is only renamed over the old one insideswapGitSourceafter the old loop has returned;defer os.RemoveAll(staging)is a no-op after a successful promote and cleans up on every failure path; a source disconnected mid-clone is not resurrected (swapGitSourcere-matches identity underk.muand returnsErrGitSourceNotFound).promoteStagedClone(api.go:1292-1311) puts the old clone back if the second rename fails — the claim in the body that a failed edit never leaves the operator without their source holds.handleGitSourcesUpdateis owner-gated, re-validates a changed URL throughValidateGitSourceURLContextbeforeResolveGitSourceDefaultBranchshells out togit ls-remote, and the sharedvalidateGitSourceFieldsis equivalent to the three checks it replaced in Connect. A resolved branch that the handler never sees still hitsValidateGitSourceBranchinInit(gitsource.go:520).ConnectGitSourcenow resolves a blank branch instead of assumingmain; with an existing clone on diskensureClonedalready failed on an unreachable remote before this PR (gitsource.go:311-317), so this is not a new offline-boot failure.
Low: a name/layer edit leaves the sync loop running on the pre-edit config. withConfig (gitsource.go:144-161) returns a copy that is published at api.go:1188, but the loop goroutine started at api.go:1127 closes over the original *GitSource. Sync → injectRepoConventions (gitsource.go:239-250) therefore keeps deriving the repo key from the stale g.config.Name: renaming org/rpeo → org/repo leaves the derived conventions page tagged repo:org/rpeo and re-injected every sync interval until restart, and the sync warn/debug logs carry the old name. Shared store and cancel func mean nothing leaks, so this is cosmetic-to-minor — but it contradicts "the live source … is rewritten in place". Simplest fix is to guard config with g.mu and mutate it in place rather than copy.
Low / open question: StopSyncLoop is awaited under the knowledge write lock. swapGitSource (api.go:1329) and DisconnectGitSource (api.go:1161) hold k.mu.Lock() while StopSyncLoop waits for the loop goroutine. git pull is ctx-cancelled promptly, but store.Reindex() (gitsource.go:238) is not, so every knowledge API call stalls for the remainder of an in-flight reindex. I checked that Reindex/InjectDerivedRepoConventions never take k.mu, so it cannot deadlock; whether a multi-second stall on a large source is acceptable is a judgement call I'll leave to you.
Scope note: the diff also carries the #17587 (inline field errors) and #17610 (busy state + default branch) fixes with their own changelog fragments; neither is on v6 yet and both issues are closed, so this PR is the vehicle for all three. Fine by me, just naming it since #17588 described them as separate landings.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against the tree at 859f6a3 (merge-base), plus the callers in src/cmd/hive/main.go:3237 and the handlers in api_knowledge.go. This looks correct to me.
What I verified:
- Metadata edit never touches the clone.
UpdateGitSourceMetadata(src/pkg/knowledge/api.go:1178) swaps inwithConfigcopy that sharesstore/cloneDir/stopSync/syncDone(gitsource.go:144), so a later Disconnect/Replace on the copy still cancels the original loop goroutine and waits on the samedonechannel. - Same-dir branch edit is staged, not reused.
sameCloneDiris computed onCloneDir()not URL (api.go:1241), so.git-suffix / scheme edits that collapse to the same slug also take the staging path.os.MkdirTempgives an empty dir, whichgit cloneaccepts;promoteStagedClonerenames old aside → staging in → restores old on failure; thedefer os.RemoveAll(staging)is a no-op after a successful promote (dir no longer exists) and cleans up on every failure path. - Remove-wins race.
swapGitSourcere-matches identity underk.mu.Lock(api.go:1322), so a source disconnected during the clone is not resurrected — andgsis never published, so no orphan loop is started. - StopSyncLoop under
k.muis fine in practice:gitSourcePullusesexec.CommandContextwith the loop ctx (gitsync.go), so cancel kills the pull promptly; the wait only lasts a reindex if one is mid-flight. GitSources()now takesRLock— a real pre-existing race fixed in passing.- Handler: owner-gated,
validateGitSourceFieldsshared with Connect so the two can't drift;hive.yamlrewrite handles both the move (drops a stale entry for the new identity) and the metadata-only path. Body matches the diff, including the v5→v6 carry-over ofkbFieldErrorand the busy-state selector fix.
One low note, pre-existing and not introduced here, but the edit flow makes it reachable more often: the different-dir path reuses an existing clone via ensureCloned → isGitRepo → gitSourcePull (src/pkg/knowledge/gitsource.go:312-317) without checking the checked-out branch. Edit A@main → B, then B → A@dev: the A clone dir was left untouched by design, so the second edit pulls main while the source reports dev. Same as Remove + re-add with a different branch today, so not a blocker; a follow-up could compare git rev-parse --abbrev-ref HEAD against config.Branch and re-clone on mismatch.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Right now the only way to fix a mistyped URL, name, subpath, branch or layer on a knowledge git source is Remove + re-add. That throws away the clone and re-indexes everything, even when only the display name was wrong. This PR lets the operator edit the source in place and only re-clones when the change requires it.
Why it is shaped this way:
{url, subpath}, the same key connect and disconnect use. Edits go throughPUT /api/knowledge/git-sourcesand are owner-gated like the other mutations, so the auth model is unchanged. The source can be moved withnew_url/new_subpath.hive.yamlentry are rewritten in place.knowledge_git_source_updateaudit row per edit, not a disconnect+connect pair, because from the operator's side it is a single action.Note on the prerequisite: #17589 (inline field errors, #17587) merged into v5, not v6, so
kbFieldError/kbClearFieldErrorwere not on v6. This PR carries that change over unchanged (static-src JS/CSS, its node test and its changelog fragment) so the edit form can reuse it here. The contents are byte-identical, so the next v5→v6 top-up should merge cleanly.Docs: the OpenAPI spec, the api-reference route tables (adding the PUT row shifted later
api.goline citations by one), the contribute API page and knowledge-curator.md are updated.static/index.htmlis regenerated from static-src/manifest.txt.Closes #17588
Closes #17583
Refs #17610 (busy-state/default-branch fix merged to v5 as #17614; this PR carries its changelog fragment byte-identical)
Addendum (#17583 maintainer repro)
button[onclick="kbAddGitSource()"]selector, so Clone & Index / Save never disabled or showed "Cloning…". It now targets#kb-subs-content [data-action="kbAddGitSource"].main, which fails for repos with another default branch. A blank branch is now sent blank; the server resolves it withgit ls-remote --symref <url> HEAD(falling back tomainonly if the remote reports no HEAD symref; ls-remote failures surface) and records the resolved branch in the saved config. Placeholder is now "Branch (blank = repo default)".error: <reason>row with Retry (reloads the form, reusing Edit/Save) and Dismiss. No server persistence added.Tests: Go table test for default-branch resolution plus a ConnectGitSource blank-branch test; JS assertions for the selector and error row.
static/index.htmlregenerated.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@clubanderson