Skip to content

Commit 54add09

Browse files
fix: improve error message for schema problems W-20495414 (#1363)
* chore: stop using deprecated schemaValidator @W-20495414@ * chore: removed DataPlanPartFileOnly type @W-20495414@ * chore: warning is displayed instead of logged @W-20495414@ * chore: integrate feedback from code review @W-20495414@ * chore: removed leading underscore @W-20495414@ * fix: error actions had old command name * refactor: align types with zod schema * fix: improve error message for schema problems * chore: comment removal --------- Co-authored-by: Joshua Feingold <jfeingold35@gmail.com>
1 parent 815eb41 commit 54add09

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

messages/importApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Data plan file %s did not validate against the schema. Errors: %s.
2020

2121
- Make sure you're importing a plan definition file.
2222

23-
- Get help with the import plan schema by running "sf data import beta tree --help".
23+
- Get help with the import plan schema by running "sf data import tree --help".
2424

2525
# error.NonStringFiles
2626

src/api/data/tree/importPlan.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
3737
const messages = Messages.loadMessages('@salesforce/plugin-data', 'importApi');
3838

3939
// the "new" type for these. We're ignoring saveRefs/resolveRefs
40-
export type EnrichedPlanPart = Partial<DataPlanPart> & {
40+
export type EnrichedPlanPart = DataPlanPart & {
4141
filePath: string;
42-
sobject: string;
4342
records: SObjectTreeInput[];
4443
};
4544
/** an accumulator for api results. Fingerprints exist to break recursion */
@@ -51,6 +50,7 @@ type ResultsSoFar = {
5150
const TREE_API_LIMIT = 200;
5251

5352
const refRegex = (object: string): RegExp => new RegExp(`^@${object}Ref\\d+$`);
53+
5454
export const importFromPlan = async (conn: Connection, planFilePath: string): Promise<ImportStatus> => {
5555
const resolvedPlanPath = path.resolve(process.cwd(), planFilePath);
5656
const logger = Logger.childFromRoot('data:import:tree:importFromPlan');
@@ -197,7 +197,7 @@ export function validatePlanContents(
197197
if (parseResults.error) {
198198
throw messages.createError('error.InvalidDataImport', [
199199
planPath,
200-
parseResults.error.issues.map((e) => e.message).join('\n'),
200+
parseResults.error.issues.map((e) => JSON.stringify(e, null, 2)).join('\n'),
201201
]);
202202
}
203203
const parsedPlans: DataImportPlanArray = parseResults.data;

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type SObjectTreeInput = Omit<BasicRecord, 'attributes'> & {
6262
};
6363
export type DataPlanPart = {
6464
sobject: string;
65-
files: Array<string | (DataPlanPart & { file: string })>;
65+
files: string[];
6666
};
6767

6868
export type SObjectTreeFileContents = {

0 commit comments

Comments
 (0)