Add ggt field {rename,remove} subcommands#2350
Merged
shardulbee merged 1 commit intomainfrom Apr 2, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 695ecf2 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix prepared fixes for all 3 issues found in the latest run.
- ✅ Fixed: Wrong failure context for field mutations
- Made AddClientError accept an operation parameter (defaulting to "add") and passed "remove field" / "rename field" from the respective subcommands.
- ✅ Fixed: Missing model path passes field validation
- Added a check in parseFieldTarget that returns a "Missing model identifier" problem when the model segment before the slash is empty.
- ✅ Fixed: Colon input misparsed in field commands
- Added fieldType presence checks in field remove and rename subcommands that reject colon-containing input with a clear error message.
Or push these changes by commenting:
@cursor push 8787309d57
Preview (8787309d57)
diff --git a/src/commands/add.ts b/src/commands/add.ts
--- a/src/commands/add.ts
+++ b/src/commands/add.ts
@@ -21,8 +21,9 @@
export class AddClientError extends GGTError {
isBug = IsBug.NO;
+ operation: string;
- constructor(error: ClientError) {
+ constructor(error: ClientError, operation = "add") {
let template = "";
if (isGraphQLErrors(error.cause)) {
@@ -38,11 +39,12 @@
}
super(template);
+ this.operation = operation;
}
protected override render(): string {
return sprint`
- ${colors.deleted(symbol.cross)} Failed to add:
+ ${colors.deleted(symbol.cross)} Failed to ${this.operation}:
${this.message}
`;
}
diff --git a/src/commands/field.ts b/src/commands/field.ts
--- a/src/commands/field.ts
+++ b/src/commands/field.ts
@@ -137,6 +137,9 @@
if (parsed.problems.length > 0) {
throw new FlagError(parsed.problems.join("\n"), { usageHint: false });
}
+ if (parsed.fieldType) {
+ throw new FlagError("Field type is not allowed for remove. Use model/field format.", { usageHint: false });
+ }
if (!flags["--force"]) {
await confirm(`Remove ${parsed.fieldName} from ${parsed.modelApiIdentifier}?`);
@@ -152,7 +155,7 @@
).removeModelField;
} catch (error) {
if (error instanceof ClientError) {
- throw new AddClientError(error);
+ throw new AddClientError(error, "remove field");
}
throw error;
}
@@ -198,11 +201,17 @@
if (source.problems.length > 0) {
throw new FlagError(source.problems.join("\n"), { usageHint: false });
}
+ if (source.fieldType) {
+ throw new FlagError("Field type is not allowed for rename. Use model/field format.", { usageHint: false });
+ }
const target = parseFieldTarget(targetInput);
if (target.problems.length > 0) {
throw new FlagError(target.problems.join("\n"), { usageHint: false });
}
+ if (target.fieldType) {
+ throw new FlagError("Field type is not allowed for rename. Use model/field format.", { usageHint: false });
+ }
if (source.modelApiIdentifier !== target.modelApiIdentifier) {
throw new FlagError(
@@ -225,7 +234,7 @@
).renameModelField;
} catch (error) {
if (error instanceof ClientError) {
- throw new AddClientError(error);
+ throw new AddClientError(error, "rename field");
}
throw error;
}
diff --git a/src/services/add/field.ts b/src/services/add/field.ts
--- a/src/services/add/field.ts
+++ b/src/services/add/field.ts
@@ -50,6 +50,10 @@
const modelApiIdentifier = input.slice(0, lastSlashIndex);
const fieldPart = input.slice(lastSlashIndex + 1);
+ if (!modelApiIdentifier) {
+ return { modelApiIdentifier: "", fieldName: "", fieldType: undefined, problems: ["Missing model identifier"] };
+ }
+
// No colon means just a field name (e.g. "post/title" for remove/rename)
if (!fieldPart.includes(":")) {
return { modelApiIdentifier, fieldName: fieldPart, fieldType: undefined, problems: [] };You can send follow-ups to this agent here.
894fa1c to
ecfdc77
Compare
scott-rc
approved these changes
Apr 1, 2026
…messages, validate empty model path
48dce93 to
695ecf2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Should be merged after https://github.com/gadget-inc/gadget/pull/20329 lands
Part of
ggt shopify