Skip to content

Commit a7153db

Browse files
fix: add message to query for errors when more than 12
1 parent e538a75 commit a7153db

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

messages/package_version_create_report.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ package version creation request ID (starts with 08c)
1818
# requestIdLong
1919

2020
The ID (starts with 08c) of the package version creation request you want to display.
21+
22+
# truncatedErrors
23+
24+
...
25+
26+
To see all errors, run: sfdx force:data:soql:query -t -q "SELECT Message FROM Package2VersionCreateRequestError WHERE ParentRequest.Id='%s'" -u %s

src/commands/force/package/beta/version/create/report.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_
1818
const pvclMessages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_create_list');
1919
const plMessages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_list');
2020

21+
const ERROR_LIMIT = 12;
2122
export class PackageVersionCreateReportCommand extends SfdxCommand {
2223
public static readonly description = messages.getMessage('cliDescription');
2324
public static readonly examples = messages.getMessage('examples').split(os.EOL);
@@ -93,11 +94,22 @@ export class PackageVersionCreateReportCommand extends SfdxCommand {
9394
if (record.Error?.length > 0) {
9495
this.ux.log('');
9596
const errors = [];
96-
record.Error.forEach((error: string) => {
97+
record.Error.slice(0, ERROR_LIMIT).forEach((error: string) => {
9798
errors.push(`(${errors.length + 1}) ${error}`);
9899
});
99100
this.ux.styledHeader(chalk.red('Errors'));
100101
this.ux.log(errors.join('\n'));
102+
103+
// Check if errors were truncated. If so, inform the user with
104+
// instructions on how to retrieve the remaining errors.
105+
if (record.Error.length > ERROR_LIMIT) {
106+
this.ux.log(
107+
messages.getMessage('truncatedErrors', [
108+
this.flags.packagecreaterequestid as string,
109+
this.hubOrg.getUsername(),
110+
])
111+
);
112+
}
101113
}
102114
}
103115
}

test/commands/force/package/packageVersionCreateReport.test.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ describe('force:package:version:create:report - tests', () => {
3434
'PropertyController: Invalid type: Schema.Property__c',
3535
'SampleDataController: Invalid type: Schema.Property__c',
3636
'SampleDataController: Invalid type: Schema.Broker__c',
37+
'PropertyController: Invalid type: Schema.Property__c',
38+
'SampleDataController: Invalid type: Schema.Property__c',
39+
'SampleDataController: Invalid type: Schema.Broker__c',
40+
'PropertyController: Invalid type: Schema.Property__c',
41+
'SampleDataController: Invalid type: Schema.Property__c',
42+
'SampleDataController: Invalid type: Schema.Broker__c',
43+
'PropertyController: Invalid type: Schema.Property__c',
44+
'SampleDataController: Invalid type: Schema.Property__c',
45+
'SampleDataController: Invalid type: Schema.Broker__c',
46+
'SampleDataController: Invalid type: Schema.Broker__c',
47+
'SampleDataController: Invalid type: Schema.Broker__c',
3748
],
3849
CreatedDate: '2022-11-03 09:21',
3950
HasMetadataRemoved: null,
@@ -117,15 +128,27 @@ describe('force:package:version:create:report - tests', () => {
117128

118129
const result = await runCmd(['-i', '08c3i000000fyoVAAQ', '-v', '[email protected]']);
119130

120-
expect(logStub.callCount).to.equal(2);
131+
expect(logStub.callCount).to.equal(3);
121132
expect(result[0]).to.deep.equal({
122133
Branch: null,
123134
CreatedBy: '0053i000001ZIyXXXX',
124135
CreatedDate: '2022-11-03 09:21',
136+
// requires 12+ errors for error truncation message
125137
Error: [
126138
'PropertyController: Invalid type: Schema.Property__c',
127139
'SampleDataController: Invalid type: Schema.Property__c',
128140
'SampleDataController: Invalid type: Schema.Broker__c',
141+
'PropertyController: Invalid type: Schema.Property__c',
142+
'SampleDataController: Invalid type: Schema.Property__c',
143+
'SampleDataController: Invalid type: Schema.Broker__c',
144+
'PropertyController: Invalid type: Schema.Property__c',
145+
'SampleDataController: Invalid type: Schema.Property__c',
146+
'SampleDataController: Invalid type: Schema.Broker__c',
147+
'PropertyController: Invalid type: Schema.Property__c',
148+
'SampleDataController: Invalid type: Schema.Property__c',
149+
'SampleDataController: Invalid type: Schema.Broker__c',
150+
'SampleDataController: Invalid type: Schema.Broker__c',
151+
'SampleDataController: Invalid type: Schema.Broker__c',
129152
],
130153
HasMetadataRemoved: null,
131154
Id: '08c3i000000fylXXXX',
@@ -135,9 +158,15 @@ describe('force:package:version:create:report - tests', () => {
135158
SubscriberPackageVersionId: null,
136159
Tag: null,
137160
});
138-
expect(logStub.secondCall.args[0]).to.equal(
161+
expect(logStub.secondCall.args[0]).to.include(
139162
'(1) PropertyController: Invalid type: Schema.Property__c\n(2) SampleDataController: Invalid type: Schema.Property__c\n(3) SampleDataController: Invalid type: Schema.Broker__c'
140163
);
164+
expect(logStub.secondCall.args[0]).to.include(
165+
'(11) SampleDataController: Invalid type: Schema.Property__c\n(12) SampleDataController: Invalid type: Schema.Broker__c'
166+
);
167+
expect(logStub.thirdCall.args[0]).to.deep.equal(
168+
'...\n\nTo see all errors, run: sfdx force:data:soql:query -t -q "SELECT Message FROM Package2VersionCreateRequestError WHERE ParentRequest.Id=\'08c3i000000fyoVAAQ\'" -u [email protected]'
169+
);
141170
});
142171
});
143172
});

0 commit comments

Comments
 (0)