Skip to content

Commit 6359421

Browse files
authored
fix(scope): improve error message when Source object is missing from local scope (#10294)
When a Version object exists locally but a referenced Source blob is missing (rare scope corruption, e.g. interrupted import), the error gave no hint on how to recover. `bit import --objects` alone won't fix it because the remote short-circuits via `returnNothingIfGivenVersionExists` when the Version hash already exists locally. The error now tells the user to run `bit import <id>@<version> --objects --all-history`, which bypasses the delta optimization and re-fetches all referenced objects.
1 parent 002af60 commit 6359421

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

scopes/scope/objects/models/model-component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,11 +1075,17 @@ consider using --ignore-missing-artifacts flag if you're sure the artifacts are
10751075
) {
10761076
componentVersion = new ComponentVersion(this, version.hash().toString());
10771077
}
1078+
const resolvedVersion = componentVersion.version;
10781079
const loadFileInstance = (ClassName) => async (file) => {
10791080
const loadP = file.file.load(repository);
10801081
const content: Source = await loadP;
10811082
if (!content)
1082-
throw new BitError(`failed loading file ${file.relativePath} from the model of ${this.id()}@${versionStr}`);
1083+
throw new BitError(
1084+
`failed loading file ${file.relativePath} (ref: ${file.file.toString()}) from the model of ${this.id()}@${resolvedVersion}.
1085+
The Source object is missing from the local scope.
1086+
To fix, run:
1087+
bit import ${this.id()}@${resolvedVersion} --objects --all-history`
1088+
);
10831089
return new ClassName({ base: '.', path: file.relativePath, contents: content.contents, test: file.test });
10841090
};
10851091
const filesP = version.files ? Promise.all(version.files.map(loadFileInstance(SourceFile))) : null;

0 commit comments

Comments
 (0)