Skip to content

Commit 58e0a47

Browse files
Fix confusing error with local feature (#834)
* obtuse and confusing error with local feature under WSL #834 * addressed review comments and modified error message accordingly * review comments addressed and error message changed as needed * error message tab removed and variable moved to if condition
1 parent 7cd7ccc commit 58e0a47

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/spec-configuration/containerFeaturesConfiguration.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,12 @@ export async function getFeatureIdType(params: CommonParams, userFeatureId: stri
698698

699699
// Legacy feature-set ID
700700
if (!userFeatureId.includes('/') && !userFeatureId.includes('\\')) {
701-
output.write(`Legacy feature '${userFeatureId}' not supported. Please check https://containers.dev/features for replacements.`, LogLevel.Error);
702-
throw new ContainerError({ description: `Legacy feature '${userFeatureId}' not supported. Please check https://containers.dev/features for replacements.` });
701+
const errorMessage = `Legacy feature '${userFeatureId}' not supported. Please check https://containers.dev/features for replacements.
702+
If you were hoping to use local Features, remember to prepend your Feature name with "./". Please check https://containers.dev/implementors/features-distribution/#addendum-locally-referenced for more information.`;
703+
output.write(errorMessage, LogLevel.Error);
704+
throw new ContainerError({
705+
description: errorMessage
706+
});
703707
}
704708

705709
// Direct tarball reference

src/test/cli.build.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ describe('Dev Containers CLI', function () {
2727

2828
describe('Command build', () => {
2929

30+
it('should fail to build with correct error message for local feature', async () => {
31+
const testFolder = `${__dirname}/configs/image-with-local-feature`;
32+
try {
33+
await shellExec(`${cli} build --workspace-folder ${testFolder} --image-name demo:v1`);
34+
} catch (error) {
35+
const res = JSON.parse(error.stdout);
36+
assert.equal(res.outcome, 'error');
37+
assert.match(res.message, /prepend your Feature name with/);
38+
}
39+
});
40+
3041
it('should correctly configure the image name to push from --image-name with --push true', async () => {
3142
const testFolder = `${__dirname}/configs/example`;
3243
try {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"image": "ubuntu:latest",
3+
"features": {
4+
"myfeature": {}
5+
}
6+
}

src/test/configs/image-with-local-feature/myfeature/devcontainer-feature.json

Whitespace-only changes.

0 commit comments

Comments
 (0)