diff --git a/README.md b/README.md index dbc6b322..bf9e42eb 100644 --- a/README.md +++ b/README.md @@ -1001,6 +1001,15 @@ listing and everything on it, and a rejection can too.** `civitai app withdraw` on a **first-version** submission is therefore destructive, which is why it asks first and needs `--yes` in a script. +πŸ” **To update a version that is still waiting for review, submit again β€” do not +withdraw it.** A new `civitai app submit` replaces your own version in review: +the old one is marked replaced, its store listing and media are kept, and +moderators see only the new one. The submit says which version it replaces (and, +on a terminal without `--yes`, asks first). A submit whose manifest declares the +**same** version as the one in review is refused with the exact bump to make +(`set "version" to 0.1.1 in block.manifest.json`). A version someone else +submitted is never replaced. + πŸ“– **The two kinds of credential, what `civitai whoami` reports (including the tri-state capability rows) and `whoami --json`: [CLI credentials and scopes](https://developer.civitai.com/site/guide/cli-auth).** @@ -2041,6 +2050,7 @@ esac - **When validation produces a result**, `civitai app validate --json` prints it in full and its `ok` field is the structured form of the same answer; a failure that produces no result at all β€” a project directory the CLI cannot **stat**, say, because it is unreadable or because a path component below it is not a directory β€” still exits `1` with **nothing on stdout**, so branch on the exit code before parsing. The full exitβ†’stdout table is in [The `--json` result shape](https://developer.civitai.com/apps/guide/validate#the-json-result-shape). - A resource that **exists but is not ready** lands here too, and deliberately not on `4`: `civitai app metrics ` for an app whose submitted version is still in review exits `1`, because the slug is right and the app does exist β€” only its analytics do not exist yet, and the error names `civitai app status ` as the next command. `4` stays reserved for a slug with no submissions at all, so the two remain separately actionable: fix the slug, versus wait for approval. - A **version regression** lands here for the same reason: `civitai app submit` refuses when the manifest version is not strictly **above the highest approved version** of that app, because approving an older (or identical) version replaces the newer live deployment. Nothing about the invocation is wrong, so it is a verdict about the project, not a `2`. `--allow-downgrade` is the deliberate-rollback escape hatch, and the guard is skipped entirely by `--package-only` or a run with no token β€” neither reaches the server. +- A **resubmit of the version already in review** lands here too: when your own version of the app is waiting for review, `civitai app submit` refuses a manifest declaring that same version and names the next patch to set, because the new submit replaces the one in review and two submissions of one version cannot be told apart. Like the version guard it reads `GET /api/v1/blocks/submissions` and is skipped by `--package-only` or a run with no token; a read that fails warns and the submit goes ahead. - A **dirty git work tree** lands here too: `civitai app submit` refuses while files that go into the bundle are uncommitted, because the bundle is packaged from what is on disk and approving one deploys code that exists in no commit. `--allow-dirty` submits the tree as it is. It **degrades rather than enforcing** β€” a directory that is not in a git repo, or a machine with no `git` on `PATH`, submits exactly as before (scaffolded apps have no repo, and that path must keep working), and a clean tree whose `HEAD` is on no remote **warns** instead of refusing. Like the version guard it is skipped by `--package-only` and by a run with no token. - **A bundle the server cannot receive** lands here for the same reason, since [#585](https://github.com/civitai/cli/issues/585): `civitai app submit` refuses BEFORE uploading when the base64 JSON body would exceed what the platform accepts, so the transfer costs nothing. Nothing about the invocation is wrong β€” the project is too big β€” which is why it is `1` and not `2`, matching the version and dirty-tree refusals above. It previously reached `2` by way of the server answering `400: Invalid JSON`. `--allow-oversize` is the escape hatch, because the ceiling is a vendored number the CLI cannot re-measure; see AGENTS.md item 31. - **An incomplete store listing** lands here too, since [#762](https://github.com/civitai/cli/pull/762): `civitai app submit` refuses while the app's listing is missing something you can fix **now** β€” a missing icon or cover, and, on an **off-site** listing whose copy you own, an empty tagline or description β€” and names the command that fixes each. Nothing about the invocation is wrong, which is why it is `1` and not `2`, matching the version, dirty-tree and oversize refusals above. `--allow-incomplete-listing` is the escape hatch; **`--yes` is not**, and the refusal says so, because `--yes` is the flag a script already passes. It is deliberately narrower than `civitai app doctor`: no screenshots, an empty category, a still-scanning asset and even a **blocked** asset are reported and not refused, because each of those remedies can end at a moderator's queue rather than at a command you can run. An **on-site** app's tagline and description come from `block.manifest.json` and are re-read only when a version is approved, so a tagline already in your manifest is reported as fixed rather than refused β€” refusing it would refuse the one submit that fixes it. Your **first** submit is what creates the listing, so nothing is refused there; the gate applies from the second on. Like the other four guards (version, dirty tree, oversize, outdated SDK) it is skipped by `--package-only` and by a run with no token. When the listing cannot be read the gate warns and the submit goes ahead (exit `0`). A scope refusal is the common case in CI: the read needs the Apps submit scope, which a `civitai login` token carries and a personal API key passes only with Full Access, so a scoped personal key skips the check on every run β€” the warning says so and, when unattended (a GitHub Actions OIDC submit, a CI environment, or no TTY), names `civitai app doctor ` from a `civitai login` session as the check to run instead. diff --git a/internal/appapi/appblocks.go b/internal/appapi/appblocks.go index 8f099ac0..5199b82b 100644 --- a/internal/appapi/appblocks.go +++ b/internal/appapi/appblocks.go @@ -575,6 +575,16 @@ type SubmitResult struct { // server that predates it), null, or malformed decodes to nil rather than // failing the submit β€” see SubmitAdvisories.UnmarshalJSON. Advisories SubmitAdvisories `json:"advisories,omitempty"` + // Replaced is the caller's own version that was waiting for review and this + // submit replaced (civitai/civitai#11502). nil when nothing was replaced or + // the server predates the field. + Replaced *SubmitReplaced `json:"replaced,omitempty"` +} + +// SubmitReplaced is SubmitResult.Replaced. +type SubmitReplaced struct { + PublishRequestID string `json:"publishRequestId"` + Version string `json:"version"` } // SubmitAdvisory is one entry of SubmitResult.Advisories. diff --git a/internal/cmd/app_submit.go b/internal/cmd/app_submit.go index d3f70ccc..4002b24d 100644 --- a/internal/cmd/app_submit.go +++ b/internal/cmd/app_submit.go @@ -357,6 +357,13 @@ Version guard: deployment on approval, which is what a repo that is behind what was last released produces naturally. Pass --allow-downgrade for a deliberate rollback. +Version-in-review guard: + When your own version of the app is still waiting for review, a submit that + would really upload REPLACES it (the store listing and media are kept). The + submit names the version it replaces and, on a terminal without --yes, asks + first; a manifest declaring the SAME version as the one in review is refused + with the exact version to set. + Dirty-tree guard: When the packaged directory is inside a git work tree, a submit that would really upload REFUSES while files that go into the bundle are uncommitted β€” @@ -683,7 +690,20 @@ Defaults to the current directory.`, if ctx == nil { ctx = context.Background() } - if err := checkVersionNotRegression(ctx, client.ListSubmissions, cmd.ErrOrStderr(), m.BlockID, m.Version, allowDowngrade); err != nil { + // One read of the caller's submissions serves both guards below. + listSubmissions := onceLister(client.ListSubmissions) + if err := checkVersionNotRegression(ctx, listSubmissions, cmd.ErrOrStderr(), m.BlockID, m.Version, allowDowngrade); err != nil { + return err + } + + // 2b'. VERSION-IN-REVIEW GUARD, after the version guard and on the + // same network read's terms (after confirmSubmit). The server + // replaces the author's own version in review with this submit; + // a same version is refused here with the bump to make, and a + // different one is announced (and confirmed on a TTY without + // --yes). See app_submit_pending_guard.go. + if err := checkPendingReplace(ctx, listSubmissions, cmd.InOrStdin(), cmd.OutOrStdout(), cmd.ErrOrStderr(), + m.BlockID, m.Version, assumeYes); err != nil { return err } @@ -947,6 +967,11 @@ func afterPlatformUpdateMerge(ctx context.Context, cmd *cobra.Command, client *a if err := checkVersionNotRegression(ctx, client.ListSubmissions, errw, m2.BlockID, m2.Version, allowDowngrade); err != nil { return nil, prov, err } + // The new version was announced or confirmed above; only a merge that + // moved it onto the version in review is refused here. + if err := checkPendingReplace(ctx, client.ListSubmissions, nil, io.Discard, errw, m2.BlockID, m2.Version, true); err != nil { + return nil, prov, err + } } outdated, err := checkSDKFloor(ctx, client.GetSDKFloor, errw, dir, m2.BuildCommand, allowOutdatedSDK) if err != nil { @@ -1121,6 +1146,9 @@ func doUploadWith(cmd *cobra.Command, client appapi.Submitter, zipBytes []byte, } base := strings.TrimRight(baseURL, "/") fmt.Fprintln(out, ui.Success(fmt.Sprintf("Submitted β€” %s is pending moderator review.", r.PublishRequestID))) + if r.Replaced != nil { + fmt.Fprintf(out, "It replaces %s (%s), which was waiting for review; its store listing and media are kept.\n", r.Replaced.PublishRequestID, r.Replaced.Version) + } printActionsRunSourceRecorded(out, r.ActionsRunSourceRecorded) printSubmitListingReadiness(out, r.Listing) printStorageMigrationWarnings(out, r.StorageMigrationWarnings) diff --git a/internal/cmd/app_submit_pending_guard.go b/internal/cmd/app_submit_pending_guard.go new file mode 100644 index 00000000..26041784 --- /dev/null +++ b/internal/cmd/app_submit_pending_guard.go @@ -0,0 +1,146 @@ +package cmd + +import ( + "context" + "errors" + "fmt" + "io" + "regexp" + "strconv" + "strings" + + "github.com/civitai/cli/internal/appapi" +) + +// THE VERSION-IN-REVIEW GUARD. +// +// The server replaces the author's OWN version still waiting for review with a +// new submit (civitai/civitai#11502): the old one is marked replaced, its draft +// store listing and media are kept, and moderators see only the new one. Before +// that, a second submit was refused ("withdraw it first"), and withdrawing a +// first version deleted its draft listing. +// +// This guard is what the CLI adds on top, and it is client-side only: +// +// - a new submit carrying the SAME version as the one in review is refused, +// naming the exact bump to make. Two submissions of one version cannot be +// told apart in history or in the approval tag. +// - otherwise the author is told the submit replaces the version in review +// (by its publish-request id) and, on a TTY without --yes, asked to confirm. +// +// The read is GET /api/v1/blocks/submissions, which is scoped to the caller's +// own submissions, so a pending row there is the caller's own: exactly the one +// the server replaces. Another user's pending version never appears, and the +// server still refuses a submit over it. +// +// Like the version guard, a failed read WARNS and proceeds: this is an accident +// preventer, the server enforces the replace rule itself. + +// ErrSameVersionInReview classifies the refusal of a submit whose version equals +// the version already waiting for review (errors.Is). Like ErrVersionRegression +// it is not tagged ErrBadRequest, so it exits 1: the project, not the +// invocation, is what is wrong. +var ErrSameVersionInReview = errors.New("submitted version is the version already waiting for review") + +var semverCore = regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$`) + +// nextPatchVersion returns MAJOR.MINOR.(PATCH+1), dropping any pre-release or +// build suffix; "" when version is not semver. The same rule App Assistant +// applies when it bumps a manifest (civitai packages/civitai-app-assistant). +func nextPatchVersion(version string) string { + m := semverCore.FindStringSubmatch(strings.TrimSpace(version)) + if m == nil { + return "" + } + patch, err := strconv.Atoi(m[3]) + if err != nil { + return "" + } + return fmt.Sprintf("%s.%s.%d", m[1], m[2], patch+1) +} + +// pendingInReview returns the caller's own submission of slug that waits for +// review, or nil. The server allows one pending submission per app. +func pendingInReview(subs []appapi.Submission, slug string) *appapi.Submission { + for i := range subs { + if appapi.SameSlug(subs[i].BlockID, slug) && strings.EqualFold(strings.TrimSpace(subs[i].Status), "pending") { + return &subs[i] + } + } + return nil +} + +// sameVersionInReviewError is the refusal for a submit carrying the version in +// review, naming the exact bump. +func sameVersionInReviewError(slug string, pending *appapi.Submission) error { + next := nextPatchVersion(pending.Version) + bump := "set a higher \"version\" in block.manifest.json" + if next != "" { + bump = fmt.Sprintf("set \"version\" to %s in block.manifest.json", next) + } + return fmt.Errorf("%w: %s@%s is already waiting for review (%s); %s, then submit again β€” the new submit replaces the version in review", + ErrSameVersionInReview, slug, pending.Version, pending.ID, bump) +} + +// replacesLine is what the author is told before a submit that replaces their +// version in review. +func replacesLine(slug, version string, pending *appapi.Submission) string { + return fmt.Sprintf("This submit replaces %s@%s, the version waiting for review (%s), with %s. Its store listing and media are kept.", + slug, pending.Version, pending.ID, version) +} + +// checkPendingReplace runs the guard described above. in is read only when +// asking (a TTY without --yes); out takes the prompt, warn the notes. +func checkPendingReplace(ctx context.Context, lister submissionLister, in io.Reader, out, warn io.Writer, + slug, version string, assumeYes bool) error { + if strings.TrimSpace(slug) == "" { + return nil + } + subs, err := lister(ctx, slug) + if err != nil { + warnf(warn, "could not check whether a version of %s is waiting for review (%v) β€” submitting anyway; a new submit replaces your version in review.", slug, err) + return nil + } + pending := pendingInReview(subs, slug) + if pending == nil { + return nil + } + if strings.TrimSpace(version) == strings.TrimSpace(pending.Version) { + return sameVersionInReviewError(slug, pending) + } + if assumeYes || !stdinIsTTY() { + // --yes (or an unattended run that already passed the submit + // confirmation): say it, do not ask. + warnf(warn, "%s", replacesLine(slug, version, pending)) + return nil + } + fmt.Fprintln(out, replacesLine(slug, version, pending)) + fmt.Fprint(out, "Replace the version in review? [y/N]: ") + // readPromptLine, not a bufio.Reader: confirmSubmit may have read from the same stdin, and + // a buffered read here could swallow input meant for a later prompt. + switch strings.ToLower(strings.TrimSpace(readPromptLine(in))) { + case "y", "yes": + return nil + default: + return fmt.Errorf("submission cancelled; %s@%s is still waiting for review", slug, pending.Version) + } +} + +// onceLister wraps lister so every call after the first returns the first +// call's answer for the same blockID: the version guard and this guard read +// the same rows, and one submit makes one read. +func onceLister(lister submissionLister) submissionLister { + type answer struct { + subs []appapi.Submission + err error + } + seen := map[string]answer{} + return func(ctx context.Context, blockID string) ([]appapi.Submission, error) { + if a, ok := seen[blockID]; ok { + return a.subs, a.err + } + subs, err := lister(ctx, blockID) + seen[blockID] = answer{subs, err} + return subs, err + } +} diff --git a/internal/cmd/app_submit_pending_guard_test.go b/internal/cmd/app_submit_pending_guard_test.go new file mode 100644 index 00000000..a0cbad31 --- /dev/null +++ b/internal/cmd/app_submit_pending_guard_test.go @@ -0,0 +1,219 @@ +package cmd + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/civitai/cli/internal/appapi" +) + +// TESTS FOR THE VERSION-IN-REVIEW GUARD (civitai/civitai#11502: a new submit +// replaces the author's own version in review). +// +// The fixture puts the pending row BETWEEN a newer withdrawn row and an older +// approved one, with another app's pending row first, and every version +// distinct: a guard reading the newest row, the wrong status or the wrong app +// compares against a different version and cannot pass by coincidence. + +const pendingSlug = "pixel-garden" + +func pendingFixture() []appapi.Submission { + return []appapi.Submission{ + {ID: "pubreq_otherapp", BlockID: "moon-phase", Version: "0.3.0", Status: "pending"}, + {ID: "pubreq_withdrawn", BlockID: pendingSlug, Version: "0.2.5", Status: "withdrawn"}, + {ID: "pubreq_inreview", BlockID: pendingSlug, Version: "0.2.4", Status: "pending"}, + {ID: "pubreq_live", BlockID: pendingSlug, Version: "0.1.9", Status: "approved"}, + } +} + +func listerOf(subs []appapi.Submission, err error) (submissionLister, *int) { + calls := 0 + return func(context.Context, string) ([]appapi.Submission, error) { + calls++ + return subs, err + }, &calls +} + +func TestPendingGuard_SameVersionRefusedWithTheExactBump(t *testing.T) { + lister, _ := listerOf(pendingFixture(), nil) + var out, warn bytes.Buffer + err := checkPendingReplace(context.Background(), lister, strings.NewReader(""), &out, &warn, pendingSlug, "0.2.4", true) + if !errors.Is(err, ErrSameVersionInReview) { + t.Fatalf("want ErrSameVersionInReview, got %v", err) + } + want := `pixel-garden@0.2.4 is already waiting for review (pubreq_inreview); set "version" to 0.2.5 in block.manifest.json, then submit again β€” the new submit replaces the version in review` + if !strings.Contains(err.Error(), want) { + t.Fatalf("refusal\n got: %s\nwant to contain: %s", err.Error(), want) + } +} + +func TestPendingGuard_DifferentVersionUnderYesIsAnnouncedNotAsked(t *testing.T) { + lister, _ := listerOf(pendingFixture(), nil) + var out, warn bytes.Buffer + if err := checkPendingReplace(context.Background(), lister, strings.NewReader(""), &out, &warn, pendingSlug, "0.3.1", true); err != nil { + t.Fatalf("want nil, got %v", err) + } + if !strings.Contains(warn.String(), "This submit replaces pixel-garden@0.2.4, the version waiting for review (pubreq_inreview), with 0.3.1.") { + t.Fatalf("announcement missing: %q", warn.String()) + } + if out.Len() != 0 { + t.Fatalf("--yes must not prompt, got %q", out.String()) + } +} + +func TestPendingGuard_TTYAsksAndOnlyAnExplicitYesProceeds(t *testing.T) { + prev := stdinIsTTY + stdinIsTTY = func() bool { return true } + t.Cleanup(func() { stdinIsTTY = prev }) + for _, tc := range []struct { + answer string + ok bool + }{{"y\n", true}, {"yes\n", true}, {"\n", false}, {"n\n", false}} { + lister, _ := listerOf(pendingFixture(), nil) + var out, warn bytes.Buffer + err := checkPendingReplace(context.Background(), lister, strings.NewReader(tc.answer), &out, &warn, pendingSlug, "0.3.1", false) + if (err == nil) != tc.ok { + t.Fatalf("answer %q: err=%v, want ok=%v", tc.answer, err, tc.ok) + } + if !strings.Contains(out.String(), "Replace the version in review? [y/N]") { + t.Fatalf("answer %q: no prompt in %q", tc.answer, out.String()) + } + } +} + +func TestPendingGuard_NothingInReviewOrAnotherAppsRowIsSilent(t *testing.T) { + // Only another app's pending row, and this app's decided rows. + subs := []appapi.Submission{pendingFixture()[0], pendingFixture()[1], pendingFixture()[3]} + lister, _ := listerOf(subs, nil) + var out, warn bytes.Buffer + // The other app's pending version, submitted for THIS app: not a same-version refusal. + if err := checkPendingReplace(context.Background(), lister, strings.NewReader(""), &out, &warn, pendingSlug, "0.3.0", true); err != nil { + t.Fatalf("want nil, got %v", err) + } + if warn.Len() != 0 || out.Len() != 0 { + t.Fatalf("want silence, got out=%q warn=%q", out.String(), warn.String()) + } +} + +func TestPendingGuard_AFailedReadWarnsAndProceeds(t *testing.T) { + lister, _ := listerOf(nil, errors.New("503 upstream")) + var out, warn bytes.Buffer + if err := checkPendingReplace(context.Background(), lister, strings.NewReader(""), &out, &warn, pendingSlug, "0.2.4", true); err != nil { + t.Fatalf("want nil, got %v", err) + } + if !strings.Contains(warn.String(), "could not check whether a version of pixel-garden is waiting for review") { + t.Fatalf("warning missing: %q", warn.String()) + } +} + +func TestOnceLister_OneReadServesBothGuards(t *testing.T) { + lister, calls := listerOf(pendingFixture(), nil) + once := onceLister(lister) + var warn bytes.Buffer + if err := checkVersionNotRegression(context.Background(), once, &warn, pendingSlug, "0.3.1", false); err != nil { + t.Fatalf("version guard: %v", err) + } + if err := checkPendingReplace(context.Background(), once, strings.NewReader(""), &warn, &warn, pendingSlug, "0.3.1", true); err != nil { + t.Fatalf("pending guard: %v", err) + } + if *calls != 1 { + t.Fatalf("want 1 submissions read, got %d", *calls) + } +} + +func TestNextPatchVersion(t *testing.T) { + for in, want := range map[string]string{ + "0.1.0": "0.1.1", + "1.2.9": "1.2.10", + "2.0.0-beta.3": "2.0.1", + "3.4.5+build.7": "3.4.6", + "not-a-version": "", + } { + if got := nextPatchVersion(in); got != want { + t.Fatalf("nextPatchVersion(%q) = %q, want %q", in, got, want) + } + } +} + +// END TO END: the real `app submit` against a fake server, so the wiring (the +// guard's call site, the shared read, the success line) is what is tested, not +// only the function. regressionFixture holds this app's approved 0.5.2 and its +// pending 0.7.1. + +// pendingE2EServer answers the submissions route (counting reads), the listing +// read, and the submit route (recording the hit, answering `replaced`). +func pendingE2EServer(t *testing.T) (srv *httptest.Server, reads *int, submitted *bool) { + t.Helper() + reads, submitted = new(int), new(bool) + srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + switch { + case strings.HasPrefix(r.URL.Path, appapi.SubmissionsPath): + *reads++ + _ = json.NewEncoder(w).Encode(map[string]any{"submissions": regressionFixture()}) + case strings.HasPrefix(r.URL.Path, listMineTestPath): + _ = json.NewEncoder(w).Encode(map[string]any{ + "result": map[string]any{"data": map[string]any{"json": []any{}}}, + }) + default: + *submitted = true + _ = json.NewEncoder(w).Encode(map[string]any{ + "publishRequestId": "pubreq_new", "slug": guardSlug, "version": "0.8.0", "status": "pending", + "replaced": map[string]any{"publishRequestId": "pubreq_pending", "version": "0.7.1"}, + }) + } + })) + t.Cleanup(srv.Close) + return srv, reads, submitted +} + +func TestAppSubmit_SameVersionInReviewIsRefusedBeforeUploading(t *testing.T) { + withStdinTTY(t, false) + tmp := t.TempDir() + writeManifestVersion(t, tmp, guardSlug, "0.7.1") + srv, _, submitted := pendingE2EServer(t) + withGuardEnv(t, srv) + + stdout, _, err := run(t, "app", "submit", tmp, "--yes") + if !errors.Is(err, ErrSameVersionInReview) { + t.Fatalf("want ErrSameVersionInReview (exit 1), got %v\nstdout:\n%s", err, stdout) + } + if !strings.Contains(err.Error(), `set "version" to 0.7.2 in block.manifest.json`) { + t.Errorf("refusal must name the exact bump, got: %s", err.Error()) + } + if *submitted { + t.Error("the submit route was hit; the guard must refuse before uploading") + } +} + +func TestAppSubmit_ANewVersionReplacesTheOneInReviewAndSaysSo(t *testing.T) { + withStdinTTY(t, false) + tmp := t.TempDir() + writeManifestVersion(t, tmp, guardSlug, "0.8.0") + srv, reads, submitted := pendingE2EServer(t) + withGuardEnv(t, srv) + + stdout, stderr, err := run(t, "app", "submit", tmp, "--yes") + if err != nil { + t.Fatalf("0.8.0 must submit; got %v\nstdout:\n%s\nstderr:\n%s", err, stdout, stderr) + } + if !*submitted { + t.Fatal("the submit route was never hit") + } + if !strings.Contains(stderr, "This submit replaces custom-generators@0.7.1, the version waiting for review (pubreq_pending), with 0.8.0.") { + t.Errorf("the replace must be announced on stderr, got:\n%s", stderr) + } + if !strings.Contains(stdout, "It replaces pubreq_pending (0.7.1), which was waiting for review") { + t.Errorf("the success output must name the replaced submission, got:\n%s", stdout) + } + // One read of the submissions route serves the version guard and this one. + if *reads != 1 { + t.Errorf("want 1 submissions read, got %d", *reads) + } +} diff --git a/internal/cmd/app_withdraw.go b/internal/cmd/app_withdraw.go index 0c53252d..2c316776 100644 --- a/internal/cmd/app_withdraw.go +++ b/internal/cmd/app_withdraw.go @@ -80,8 +80,9 @@ func newAppWithdrawCmd() *cobra.Command { cmd := &cobra.Command{ Use: "withdraw [pubreq-id]", Short: "Withdraw your own pending App submission", - Long: `Withdraw your own pending App submission so you can resubmit a new bundle -for the same slug. + Long: `Withdraw your own pending App submission. To UPDATE a version that is still in +review, do not withdraw it: raise the version and run civitai app submit again, +which replaces the version in review and keeps its store listing. πŸ”΄ THIS IS NOT A FREE REPAIR β€” ` + strings.Join(wrapRunes(withdrawDiscardsListing+".", 78), "\n") + ` diff --git a/internal/cmd/exitcodes_doc.go b/internal/cmd/exitcodes_doc.go index 69532d4f..97c82bb1 100644 --- a/internal/cmd/exitcodes_doc.go +++ b/internal/cmd/exitcodes_doc.go @@ -138,6 +138,8 @@ var exitCodeDocs = []ExitCodeDoc{ // path is well-formed) and the PROJECT is wrong relative to what is // published. Pinned by TestVersionRegressionExitsGeneric. "A **version regression** lands here for the same reason: `civitai app submit` refuses when the manifest version is not strictly **above the highest approved version** of that app, because approving an older (or identical) version replaces the newer live deployment. Nothing about the invocation is wrong, so it is a verdict about the project, not a `2`. `--allow-downgrade` is the deliberate-rollback escape hatch, and the guard is skipped entirely by `--package-only` or a run with no token β€” neither reaches the server.", + // A resubmit of the version already in review: same project-not-invocation argument. + "A **resubmit of the version already in review** lands here too: when your own version of the app is waiting for review, `civitai app submit` refuses a manifest declaring that same version and names the next patch to set, because the new submit replaces the one in review and two submissions of one version cannot be told apart. Like the version guard it reads `GET /api/v1/blocks/submissions` and is skipped by `--package-only` or a run with no token; a read that fails warns and the submit goes ahead.", // πŸ”΄ ADDED for the dirty-work-tree guard (issue #411). Same code and // the same argument as the version regression above it: the // invocation is well-formed and the PROJECT is wrong β€” here, its diff --git a/internal/scaffold/templates/page-money/README.md.tmpl b/internal/scaffold/templates/page-money/README.md.tmpl index ecc95a40..3027553d 100644 --- a/internal/scaffold/templates/page-money/README.md.tmpl +++ b/internal/scaffold/templates/page-money/README.md.tmpl @@ -853,13 +853,9 @@ today**; you cannot approve your own app. Track it with `civitai app status`. **full-scope personal API key** (a **default** `civitai login` token mints read-only and can't spend); confirm with `civitai buzz` / `civitai whoami`. See the live-mode prerequisite above. -- Need to change the bundle while a request is still `pending`? **Withdraw your - own pending submission** and resubmit a different one: - - ```bash - civitai app withdraw # the pubreq id from `civitai app status` - ``` - - Only a `pending` request can be withdrawn (an already-approved/rejected one - cannot). Withdrawing is idempotent and frees the slug so a fresh - `civitai app submit` can take its place. +- Need to change the bundle while a request is still `pending`? **Raise the + version in `block.manifest.json` and submit again** β€” the new submit replaces + your own version in review and keeps its store listing and media. Do not + withdraw it first: withdrawing a first version deletes its store listing. + (`civitai app withdraw ` is for abandoning a submission, not for + updating one.)