From 41e9f2ec9028cb9c233fe2df3b17f3cb269ee4ce Mon Sep 17 00:00:00 2001 From: Tami Takamiya Date: Wed, 21 Aug 2024 12:45:37 -0400 Subject: [PATCH 1/5] Disable Enhanced Context in VS Code (#1517) --- src/features/lightspeed/inlineSuggestions.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/features/lightspeed/inlineSuggestions.ts b/src/features/lightspeed/inlineSuggestions.ts index 9ff3f4ad4..074e166ed 100644 --- a/src/features/lightspeed/inlineSuggestions.ts +++ b/src/features/lightspeed/inlineSuggestions.ts @@ -29,7 +29,6 @@ import { IAnsibleFileType } from "../../interfaces/lightspeed"; import { getAnsibleFileType } from "../utils/ansible"; import { LightSpeedServiceSettings } from "../../interfaces/extensionSettings"; import { SuggestionDisplayed } from "./inlineSuggestion/suggestionDisplayed"; -import { getAdditionalContext } from "./inlineSuggestion/additionalContext"; let inlineSuggestionData: InlineSuggestionEvent = {}; let inlineSuggestionDisplayTime: Date; @@ -740,18 +739,6 @@ async function requestInlineSuggest( completionData.model = userProvidedModel; } - if (rhUserHasSeat) { - const additionalContext = getAdditionalContext( - parsedAnsibleDocument, - documentDirPath, - documentFilePath, - ansibleFileType, - vscode.workspace.workspaceFolders, - ); - if (completionData.metadata) { - completionData.metadata.additionalContext = additionalContext; - } - } console.log( `[inline-suggestions] ${getCurrentUTCDateTime().toISOString()}: Completion request sent to Ansible Lightspeed.`, ); From 7b16899351ffde94fa2fd70ec25e1a86ad903cec Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Tue, 27 Aug 2024 21:03:06 +0100 Subject: [PATCH 2/5] AAP-29861: WCA: Handle 'HTTP404: Failed to get remaining capacity' response (#1519) --- src/features/lightspeed/errors.ts | 8 ++++++++ .../lightspeed/utils/handleApiError.test.ts | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/features/lightspeed/errors.ts b/src/features/lightspeed/errors.ts index be73db07e..c4632ec4d 100644 --- a/src/features/lightspeed/errors.ts +++ b/src/features/lightspeed/errors.ts @@ -259,6 +259,14 @@ ERRORS.addError( ), ); +ERRORS.addError( + 418, + new Error( + "error__wca_instance_deleted", + "IBM watsonx Code Assistant instance associated with your Model Id has been deleted. Please contact your administrator.", + ), +); + ERRORS.addError( 500, new Error( diff --git a/test/units/lightspeed/utils/handleApiError.test.ts b/test/units/lightspeed/utils/handleApiError.test.ts index 5ad5fdc62..ca4d7d359 100644 --- a/test/units/lightspeed/utils/handleApiError.test.ts +++ b/test/units/lightspeed/utils/handleApiError.test.ts @@ -288,6 +288,22 @@ describe("testing the error handling", () => { }); // ================================= + // ================================= + // HTTP 418 + // --------------------------------- + it("err WCA instance deleted", () => { + const error = mapError( + createError(418, { + code: "error__wca_instance_deleted", + }), + ); + assert.equal( + error.message, + "IBM watsonx Code Assistant instance associated with your Model Id has been deleted. Please contact your administrator.", + ); + }); + // ================================= + // ================================= // HTTP 429 // --------------------------------- From 38caeacf947dadf437fd0c8b3a195aa6c33ff4c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 17:01:30 +0000 Subject: [PATCH 3/5] chore: pre-commit autoupdate (#1527) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/streetsidesoftware/cspell-cli: v8.13.1 → v8.13.3](https://github.com/streetsidesoftware/cspell-cli/compare/v8.13.1...v8.13.3) - [github.com/alessandrojcm/commitlint-pre-commit-hook: v9.16.0 → v9.17.0](https://github.com/alessandrojcm/commitlint-pre-commit-hook/compare/v9.16.0...v9.17.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb44ae4fe..5d9cff15a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ exclude: > minimum_pre_commit_version: 2.9.0 # types_or repos: - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.13.1 + rev: v8.13.3 hooks: - id: cspell # name: Spell check with cspell @@ -174,7 +174,7 @@ repos: docs/development/webview_guide.md $ - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v9.16.0 + rev: v9.17.0 hooks: - id: commitlint stages: [commit-msg] From a92b183ad51f448ae5ad4a919892c55399d18fc1 Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Wed, 4 Sep 2024 12:58:10 +0100 Subject: [PATCH 4/5] AAP-27481: Lightspeed Service to prevent users from submitting invalid multitask requests (#1528) --- src/features/lightspeed/api.ts | 6 ++-- src/features/lightspeed/errors.ts | 27 +++++++++++++---- .../lightspeed/utils/handleApiError.test.ts | 30 ++++++++++++++++++- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/features/lightspeed/api.ts b/src/features/lightspeed/api.ts index 25d40171f..e7352c6f6 100644 --- a/src/features/lightspeed/api.ts +++ b/src/features/lightspeed/api.ts @@ -145,7 +145,9 @@ export class LightSpeedAPI { const err = error as AxiosError; const mappedError: IError = await mapError(err); if (!(await this._oneClickTrialProvider.showPopup(mappedError))) { - vscode.window.showErrorMessage(mappedError.message ?? UNKNOWN_ERROR); + vscode.window.showErrorMessage( + `${mappedError.message ?? UNKNOWN_ERROR} ${mappedError.detail ?? ""}`, + ); } return {} as CompletionResponseParams; } finally { @@ -233,7 +235,7 @@ export class LightSpeedAPI { } catch (error) { const err = error as AxiosError; const mappedError: IError = await mapError(err); - const errorMessage: string = mappedError.message ?? UNKNOWN_ERROR; + const errorMessage: string = `${mappedError.message ?? UNKNOWN_ERROR} ${mappedError.detail ?? ""}`; if (showInfoMessage) { vscode.window.showErrorMessage(errorMessage); } else { diff --git a/src/features/lightspeed/errors.ts b/src/features/lightspeed/errors.ts index c4632ec4d..08eeff0aa 100644 --- a/src/features/lightspeed/errors.ts +++ b/src/features/lightspeed/errors.ts @@ -69,21 +69,38 @@ class Errors { }); if (e) { + const responseErrorData = < + AxiosError<{ code?: string; message?: unknown }> + >err?.response?.data; + // If the Error does not have a default message use the payload message let message = e.message; if (message === undefined) { - const responseErrorData = < - AxiosError<{ code?: string; message?: string }> - >err?.response?.data; message = Object.prototype.hasOwnProperty.call( responseErrorData, "message", ) - ? (responseErrorData.message as string) + ? responseErrorData.message : "unknown"; } + + let detail: string = ""; + if (typeof responseErrorData.message == "string") { + detail = responseErrorData.message ?? ""; + } else if (Array.isArray(responseErrorData.message)) { + const messages = responseErrorData.message as []; + messages.forEach((value: string, index: number) => { + detail = + detail + + "(" + + (index + 1) + + ") " + + value + + (index < messages.length - 1 ? " " : ""); + }); + } + // Clone the Error to preserve the original definition - const detail = err.response?.data; return new Error(e.code, message, detail, e.check); } diff --git a/test/units/lightspeed/utils/handleApiError.test.ts b/test/units/lightspeed/utils/handleApiError.test.ts index ca4d7d359..52ee136c9 100644 --- a/test/units/lightspeed/utils/handleApiError.test.ts +++ b/test/units/lightspeed/utils/handleApiError.test.ts @@ -77,7 +77,7 @@ describe("testing the error handling", () => { assert.equal(error.message, "Bad Request response. Please try again."); }); - it("err Postprocessing error", () => { + it("err Preprocessing error", () => { const error = mapError( createError(400, { code: "error__preprocess_invalid_yaml", @@ -89,6 +89,34 @@ describe("testing the error handling", () => { ); }); + it("err Preprocessing error with simple detail", () => { + const error = mapError( + createError(400, { + code: "error__preprocess_invalid_yaml", + message: "A simple error.", + }), + ); + assert.equal( + error.message, + "An error occurred pre-processing the inline suggestion due to invalid YAML. Please contact your administrator.", + ); + assert.equal(error.detail, "A simple error."); + }); + + it("err Preprocessing error with complex detail", () => { + const error = mapError( + createError(400, { + code: "error__preprocess_invalid_yaml", + message: ["error 1", "error 2"], + }), + ); + assert.equal( + error.message, + "An error occurred pre-processing the inline suggestion due to invalid YAML. Please contact your administrator.", + ); + assert.equal(error.detail, "(1) error 1 (2) error 2"); + }); + it("err Feedback validation error", () => { const error = mapError( createError(400, { From e0596a15354e230819ca5de1d0b75c1b68ed1537 Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Thu, 5 Sep 2024 12:21:25 +0200 Subject: [PATCH 5/5] README: add Forum (#1525) * README: add Forum * chore: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update docs/README.md Co-authored-by: Don Naro * chore: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Don Naro --- docs/README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 90c5a92e3..ab8dd8957 100644 --- a/docs/README.md +++ b/docs/README.md @@ -261,7 +261,41 @@ to get started with developing the extension. ## Contact -- [Ansible Developer Tools matrix channel](https://matrix.to/#/#devtools:ansible.im) +We welcome your feedback, questions and ideas. Here's how to reach the +community. + +### Forum + +Join the [Ansible Forum](https://forum.ansible.com) as a single starting point +and our default communication platform for questions and help, development +discussions, events, and much more. +[Register](https://forum.ansible.com/signup?) to join the community. Search by +categories and tags to find interesting topics or start a new one; subscribe +only to topics you need! + +- [Get Help](https://forum.ansible.com/c/help/6): get help or help others. + Please add appropriate tags if you start new discussions, for example + `vscode-ansible`. +- [Posts tagged with 'vscode-ansible'](https://forum.ansible.com/tag/vscode-ansible): + subscribe to participate in project-related conversations. +- [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with + fellow enthusiasts. +- [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide + announcements including social events. The + [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn), + which is used to announce releases and important changes, can also be found + here. + +See +`Navigating the Ansible forum `\_ +for some practical advice on finding your way around. + +### Matrix + +- [#devtools:ansible.im](https://matrix.to/#/#devtools:ansible.im): a chat + channel via the Matrix protocol. See the + [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html#real-time-chat) + to learn how to join. ## Credit