kubernetes/kops · warning

Edit cancelled: no valid changes were saved.

Error message

Edit cancelled: no valid changes were saved.

What it means

When the previous save produced a validation error (containsError) and the user re-saves the editor with no effective changes after comment stripping, kops aborts with "Edit cancelled: no valid changes were saved.". It prevents silently re-submitting identical invalid content, and preserves the temp file so the user can keep editing.

Source

Thrown at cmd/kops/edit_instancegroup.go:203

		results.header.writeTo(buf)
		results.header.flush()

		if !containsError {
			buf.Write(raw)
		} else {
			buf.Write(stripComments(edited))
		}

		// launch the editor
		editedDiff := edited
		edited, file, err = editor.LaunchTempFile(fmt.Sprintf("%s-edit-", filepath.Base(os.Args[0])), ext, buf)
		if err != nil {
			return preservedFile(fmt.Errorf("error launching editor: %v", err), results.file, out)
		}

		if containsError {
			if bytes.Equal(stripComments(editedDiff), stripComments(edited)) {
				return preservedFile(fmt.Errorf("%s", "Edit cancelled: no valid changes were saved."), file, out)
			}
		}

		if len(results.file) > 0 {
			try.RemoveFile(results.file)
		}

		if bytes.Equal(stripComments(raw), stripComments(edited)) {
			try.RemoveFile(file)
			fmt.Fprintln(out, "Edit cancelled: no changes made.")
			return nil
		}

		lines, err := hasLines(bytes.NewBuffer(edited))
		if err != nil {
			return preservedFile(err, file, out)
		}
		if !lines {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Actually fix the validation problem reported before the edit (the prior error message states what was invalid)
  2. If you want to abandon the edit, remove/blank the substantive fields so content differs, or Ctrl-C out of the command
  3. Edit the preserved temp file (path is printed) and re-apply, or use `kops replace -f file.yaml` after fixing offline
Defensive patterns

Strategy: validation

Validate before calling

before := stripComments(buf.Bytes())
// after editing, before saving, confirm substantive content changed
if bytes.Equal(before, stripComments(edited)) {
    return errors.New("no substantive changes made; fix the reported validation error or abort")
}

Try / catch

if err := runEdit(); err != nil {
    if strings.Contains(err.Error(), "Edit cancelled") {
        // user made no changes in an error round; surface the original validation error
    }
}

Prevention

When it happens

Trigger: In `kops edit instancegroup`, after a failed validation round, saving the editor without modifying any non-comment content — stripComments(editedDiff) equals stripComments(edited).

Common situations: User opens the editor during an error round-trip, changes nothing, and hits :wq expecting the loop to end; an editor auto-format feature reflows whitespace/comments only.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5b30a2ea3fe0839d. Report an issue: GitHub.