Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Zowe deps to fix handling of invalid ds member names #2807

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"vscode": "^1.53.2"
},
"dependencies": {
"@zowe/cli": "7.23.6",
"@zowe/cli": "7.24.0",
"vscode-nls": "4.1.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@types/vscode": "^1.53.2",
"@zowe/cli": "7.23.6",
"@zowe/cli": "7.24.0",
"@zowe/secrets-for-zowe-sdk": "7.18.6",
"handlebars": "^4.7.7",
"semver": "^7.5.3"
Expand Down
5 changes: 5 additions & 0 deletions packages/zowe-explorer-ftp-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ const config = {
},
],
},
{
test: /\.mjs$/,
include: /markdown-it/,
type: "javascript/auto",
},
],
},
plugins: [new webpack.BannerPlugin(fs.readFileSync("../../scripts/LICENSE_HEADER", "utf-8"))],
Expand Down
6 changes: 2 additions & 4 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

### Bug fixes

## `2.15.2`
- Fixed error that could occur when listing data set members that contain control characters in the name [#2807](https://github.com/zowe/zowe-explorer-vscode/pull/2807)

### New features and enhancements
## `2.15.2`

### Bug fixes

Expand All @@ -19,8 +19,6 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

## `2.15.1`

### New features and enhancements

### Bug fixes

- Fixed issue where VS Code quick pick separators were used in environments that did not support the feature. [#2771](https://github.com/zowe/vscode-extension-for-zowe/pull/2771)
Expand Down
11 changes: 6 additions & 5 deletions packages/zowe-explorer/__tests__/__unit__/ZoweNode.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,17 @@ describe("Unit Tests (Jest)", () => {
return {
success: true,
apiResponse: {
items: [{ member: "BADMEM\ufffd" }, { member: "GOODMEM1" }],
items: [{ member: "MEMBER1" }],
returnedRows: 3,
},
};
});
Object.defineProperty(List, "allMembers", { value: allMembers });
const pdsChildren = await pds.getChildren();
expect(pdsChildren[0].label).toEqual("BADMEM\ufffd");
expect(pdsChildren[0].contextValue).toEqual(globals.DS_FILE_ERROR_CONTEXT);
expect(pdsChildren[1].label).toEqual("GOODMEM1");
expect(pdsChildren[1].contextValue).toEqual(globals.DS_MEMBER_CONTEXT);
expect(pdsChildren[0].label).toEqual("MEMBER1");
expect(pdsChildren[0].contextValue).toEqual(globals.DS_MEMBER_CONTEXT);
expect(pdsChildren[1].label).toEqual("2 members with errors");
expect(pdsChildren[1].contextValue).toEqual(globals.DS_FILE_ERROR_MEMBER_CONTEXT);
getSessionNodeSpy.mockRestore();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ describe("Dataset Tree Unit Tests - Function getChildren", () => {
});
const sampleChildren: ZoweDatasetNode[] = [nodeOk, nodeImpError, nodeMigrated];
sampleChildren[0].command = { command: "zowe.ds.ZoweNode.openPS", title: "", arguments: [sampleChildren[0]] };
sampleChildren[1].command = { command: "zowe.placeholderCommand", title: "" };

const children = await testTree.getChildren(testTree.mSessionNodes[1]);
expect(children.map((c) => c.label)).toEqual(sampleChildren.map((c) => c.label));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ async function createGlobalMocks() {
"zowe.jobs.deleteProfile",
"zowe.issueTsoCmd",
"zowe.issueMvsCmd",
"zowe.placeholderCommand",
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"getChildren.search": "Use the search button to display data sets",
"getChildren.error.invalidNode": "Invalid node",
"getChildren.responses.error": "The response from Zowe CLI was not successful",
"getChildren.invalidMember": "Cannot access member with control characters in the name: {0}",
"getChildren.invalidMember": "{0} members failed to load due to invalid name errors for {1}",
"getChildren.noDataset": "No data sets found",
"getDataSets.error.sessionMissing": "Profile auth error",
"getDataSets.error.additionalDetails": "Profile is not authenticated, please log in to continue",
Expand Down
5 changes: 5 additions & 0 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,11 @@
"command": "zowe.uss.openWithEncoding",
"title": "%openWithEncoding%",
"category": "Zowe Explorer"
},
{
"command": "zowe.placeholderCommand",
"title": "%zowe.placeholderCommand%",
"enablement": "false"
}
],
"menus": {
Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer/resources/dark/fileError.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/zowe-explorer/resources/light/fileError.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 30 additions & 9 deletions packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
*
* @returns {Promise<ZoweDatasetNode[]>}
*/
public async getChildren(): Promise<ZoweDatasetNode[]> {

Check warning on line 138 in packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts

View workflow job for this annotation

GitHub Actions / lint

Async method 'getChildren' has a complexity of 36. Maximum allowed is 15
ZoweLogger.trace("ZoweDatasetNode.getChildren called.");
if (!this.pattern && contextually.isSessionNotFav(this)) {
return [
Expand Down Expand Up @@ -201,6 +201,7 @@
contextOverride: globals.DS_FILE_ERROR_CONTEXT,
profile: this.getProfile(),
});
temp.command = { command: "zowe.placeholderCommand", title: "" };
temp.errorDetails = item.error; // Save imperative error to avoid extra z/OS requests
elementChildren[temp.label.toString()] = temp;
// Creates a ZoweDatasetNode for a migrated dataset
Expand Down Expand Up @@ -246,29 +247,46 @@
elementChildren[temp.label.toString()] = temp;
} else {
// Creates a ZoweDatasetNode for a PDS member
const memberInvalid = item.member?.includes("\ufffd");
const cachedEncoding = this.getSessionNode().encodingMap[`${item.dsname as string}(${item.member as string})`];
const temp = new ZoweDatasetNode({
label: item.member,
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: this,
contextOverride: memberInvalid ? globals.DS_FILE_ERROR_CONTEXT : undefined,
encoding: cachedEncoding,
profile: this.getProfile(),
});
if (!memberInvalid) {
temp.command = { command: "zowe.ds.ZoweNode.openPS", title: "", arguments: [temp] };
} else {
temp.errorDetails = new zowe.imperative.ImperativeError({
msg: localize("getChildren.invalidMember", "Cannot access member with control characters in the name: {0}", item.member),
});
}
temp.command = { command: "zowe.ds.ZoweNode.openPS", title: "", arguments: [temp] };

// get user and last modified date for sorting, if available
temp.updateStats(item);
elementChildren[temp.label.toString()] = temp;
}
}

if (
response.apiResponse.items &&
response.apiResponse.returnedRows &&
response.apiResponse.items.length < response.apiResponse.returnedRows
) {
const invalidMemberCount = response.apiResponse.returnedRows - response.apiResponse.items.length;
const temp = new ZoweDatasetNode({
label: `${invalidMemberCount} members with errors`,
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: this,
contextOverride: globals.DS_FILE_ERROR_MEMBER_CONTEXT,
profile: this.getProfile(),
});
temp.command = { command: "zowe.placeholderCommand", title: "" };
temp.errorDetails = new zowe.imperative.ImperativeError({
msg: localize(
"getChildren.invalidMember",
"{0} members failed to load due to invalid name errors for {1}",
invalidMemberCount,
this.label as string
),
});
elementChildren[temp.label.toString()] = temp;
}
}

this.dirty = false;
Expand Down Expand Up @@ -313,10 +331,13 @@
* @returns A function that sorts 2 nodes based on the given sorting method
*/
public static sortBy(sort: NodeSort): (a: IZoweDatasetTreeNode, b: IZoweDatasetTreeNode) => number {
return (a, b): number => {

Check warning on line 334 in packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts

View workflow job for this annotation

GitHub Actions / lint

Arrow function has a complexity of 33. Maximum allowed is 15
const aParent = a.getParent();
if (aParent == null || !contextually.isPds(aParent)) {
return (a.label as string) < (b.label as string) ? -1 : 1;
} else if (a.contextValue === globals.DS_FILE_ERROR_MEMBER_CONTEXT || b.contextValue === globals.DS_FILE_ERROR_MEMBER_CONTEXT) {
// Keep invalid member node at bottom ("N members with errors")
return a.contextValue === globals.DS_FILE_ERROR_MEMBER_CONTEXT ? 1 : -1;
}

const sortLessThan = sort.direction == SortDirection.Ascending ? -1 : 1;
Expand Down Expand Up @@ -498,7 +519,7 @@
return responses;
}

public async openDs(forceDownload: boolean, previewMember: boolean, datasetProvider: IZoweTree<IZoweDatasetTreeNode>): Promise<void> {

Check warning on line 522 in packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts

View workflow job for this annotation

GitHub Actions / lint

Async method 'openDs' has a complexity of 21. Maximum allowed is 15
ZoweLogger.trace("ZoweDatasetNode.openDs called.");
await datasetProvider.checkCurrentProfile(this);

Expand Down
3 changes: 2 additions & 1 deletion packages/zowe-explorer/src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export let DS_DIR: string;
export let CONFIG_PATH; // set during activate
export let ISTHEIA = false; // set during activate
export let LOG: imperative.Logger;
export const COMMAND_COUNT = 118;
export const COMMAND_COUNT = 119;
export const MAX_SEARCH_HISTORY = 5;
export const MAX_FILE_HISTORY = 10;
export const MS_PER_SEC = 1000;
Expand All @@ -60,6 +60,7 @@ export const DS_MEMBER_CONTEXT = "member";
export const DS_MEMBER_BINARY_CONTEXT = "memberBinary";
export const DS_MIGRATED_FILE_CONTEXT = "migr";
export const DS_FILE_ERROR_CONTEXT = "fileError";
export const DS_FILE_ERROR_MEMBER_CONTEXT = "fileError_member";
export const USS_SESSION_CONTEXT = "ussSession";
export const USS_DIR_CONTEXT = "directory";
export const USS_FAV_DIR_CONTEXT = "directory_fav";
Expand Down
5 changes: 5 additions & 0 deletions packages/zowe-explorer/src/shared/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ export function registerCommonCommands(context: vscode.ExtensionContext, provide
}
})
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.placeholderCommand", () => {
// This command does nothing, its here to let us disable individual items in the tree view
})
);
}
}

Expand Down
5 changes: 5 additions & 0 deletions packages/zowe-explorer/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const config = {
},
],
},
{
test: /\.mjs$/,
include: /markdown-it/,
type: "javascript/auto",
},
],
},
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion samples/uss-profile-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"watch": "tsc -watch -p ./"
},
"dependencies": {
"@zowe/cli": "7.23.6",
"@zowe/cli": "7.24.0",
"@zowe/zowe-explorer-api": "file:../../packages/zowe-explorer-api",
"ssh2-sftp-client": "^9.1.0"
},
Expand Down
Loading
Loading