Skip to content

Commit

Permalink
Catch errors in case there are any when retrieving package or tool data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovidiu Rusu committed Oct 31, 2024
1 parent 62052f1 commit 04e2618
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
6 changes: 0 additions & 6 deletions sema4ai/src/sema4ai_code/robocorp_language_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,12 +1809,6 @@ def _agent_cli_version(self, download_if_missing=True) -> ActionResultDict:
download_if_missing=download_if_missing
).as_dict()

def m_action_server_version(self, download_if_missing=True) -> ActionResultDict:
return self._action_server_version(download_if_missing=download_if_missing)

def m_agent_cli_version(self, download_if_missing=True) -> ActionResultDict:
return self._agent_cli_version(download_if_missing=download_if_missing)

@command_dispatcher(commands.SEMA4AI_CREATE_AGENT_PACKAGE_INTERNAL)
def _create_agent_package(
self, params: CreateAgentPackageParamsDict
Expand Down
32 changes: 23 additions & 9 deletions sema4ai/vscode-client/src/rcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pathModule from "path";
import * as os from "os";
import { configure as configureXHR } from "./requestLight";
import { fileExists, getExtensionRelativeFile } from "./files";
import { CancellationToken, extensions, Progress, ProgressLocation, window, workspace } from "vscode";
import { CancellationToken, commands, extensions, Progress, ProgressLocation, window, workspace } from "vscode";
import { logError, OUTPUT_CHANNEL } from "./channel";
import { Timing } from "./time";
import { execFilePromise, ExecFileReturn, mergeEnviron } from "./subprocess";
Expand All @@ -14,6 +14,7 @@ import { runAsAdminWin32 } from "./extensionCreateEnv";
import { GLOBAL_STATE, langServer } from "./extension";
import { downloadWithProgress, DownloadProgress } from "./http";
import * as roboCommands from "./robocorpCommands";
import { ActionResult } from "./protocols";

let lastPrintedRobocorpHome: string = "";

Expand Down Expand Up @@ -454,12 +455,16 @@ async function collectToolsVersions(rccLocation: string): Promise<any> {
const rccVersion: any = await execFilePromise(rccLocation, ["--version"], {});
toolsVersions["rcc"] = rccVersion.stdout.trim();

const actionServerVersion: any = await langServer.sendRequest("actionServerVersion", {
download_if_missing: false,
});
const actionServerVersion: ActionResult<any> = await commands.executeCommand(
roboCommands.SEMA4AI_ACTION_SERVER_VERSION_INTERNAL,
{ download_if_missing: false }
);
toolsVersions["action-server"] = actionServerVersion?.result?.trim() || "";

const agentCliVersion: any = await langServer.sendRequest("agentCliVersion", { download_if_missing: false });
const agentCliVersion: ActionResult<any> = await commands.executeCommand(
roboCommands.SEMA4AI_AGENT_CLI_VERSION_INTERNAL,
{ download_if_missing: false }
);
toolsVersions["action-cli"] = agentCliVersion?.result?.trim() || "";

return toolsVersions;
Expand All @@ -486,12 +491,21 @@ export async function submitIssue(

const metadata = await collectIssueBaseMetadata();

const currentPackages: any = await langServer.sendRequest("listRobots");
const toolsVersions: any = await collectToolsVersions(rccLocation);
try {
const currentPackages: any = await langServer.sendRequest("listRobots");
metadata["packages"] = currentPackages.result;
} catch (error) {
metadata["packages"] = `Error retrieving robot packages: ${error.message || error}`;
}

try {
const toolsVersions: any = await collectToolsVersions(rccLocation);
metadata["tools"] = toolsVersions;
} catch (error) {
metadata["tools"] = `Error retrieving tools versions: ${error.message || error}`;
}

// Add required metadata info from parameters.
metadata["tools"] = toolsVersions;
metadata["packages"] = currentPackages.result;
metadata["dialogMessage"] = dialogMessage;
metadata["email"] = email;
metadata["errorName"] = errorName;
Expand Down

0 comments on commit 04e2618

Please sign in to comment.