Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: update how ky handle error (#34735)
Stephen Zhou63bfba0bdbbb
diff --git a/dev/start-docker-compose b/dev/start-docker-composeindex aa4f66a6cf5..1321c3210f3 100755--- a/dev/start-docker-compose+++ b/dev/start-docker-compose@@ -1,8 +1,8 @@-#!/usr/bin/env bash-set -euo pipefail--SCRIPT_DIR="$(dirname "$(realpath "$0")")"-ROOT="$(dirname "$SCRIPT_DIR")"--cd "$ROOT/docker"-docker compose --env-file middleware.env -f docker-compose.middleware.yaml -p dify up -d+#!/usr/bin/env bash+set -euo pipefail++SCRIPT_DIR="$(dirname "$(realpath "$0")")"+ROOT="$(dirname "$SCRIPT_DIR")"++cd "$ROOT/docker"+docker compose --env-file middleware.env -f docker-compose.middleware.yaml -p dify up -ddiff --git a/e2e/features/smoke/unauthenticated-entry.feature b/e2e/features/smoke/unauthenticated-entry.featurenew file mode 100644index 00000000000..a2783c1cba2--- /dev/null+++ b/e2e/features/smoke/unauthenticated-entry.feature@@ -0,0 +1,7 @@+@smoke @unauthenticated+Feature: Unauthenticated app console entry+ Scenario: Redirect to the sign-in page when opening the apps console without logging in+ Given I am not signed in+ When I open the apps console+ Then I should be redirected to the signin page+ And I should see the "Sign in" buttondiff --git a/e2e/features/step-definitions/common/auth.steps.ts b/e2e/features/step-definitions/common/auth.steps.tsindex bf03c2d8f43..bed35244c57 100644--- a/e2e/features/step-definitions/common/auth.steps.ts+++ b/e2e/features/step-definitions/common/auth.steps.ts@@ -9,3 +9,10 @@ Given('I am signed in as the default E2E admin', async function (this: DifyWorld'text/plain',)})++Given('I am not signed in', async function (this: DifyWorld) {+ this.attach(+ 'Using a clean browser context without the shared authenticated storage state.',+ 'text/plain',+ )+})diff --git a/e2e/features/step-definitions/common/navigation.steps.ts b/e2e/features/step-definitions/common/navigation.steps.tsindex b18ff035fa6..28e6953d65d 100644--- a/e2e/features/step-definitions/common/navigation.steps.ts+++ b/e2e/features/step-definitions/common/navigation.steps.ts@@ -10,6 +10,10 @@ Then('I should stay on the apps console', async function (this: DifyWorld) {await expect(this.getPage()).toHaveURL(/\/apps(?:\?.*)?$/)})+Then('I should be redirected to the signin page', async function (this: DifyWorld) {+ await expect(this.getPage()).toHaveURL(/\/signin(?:\?.*)?$/)+})+Then('I should see the {string} button', async function (this: DifyWorld, label: string) {await expect(this.getPage().getByRole('button', { name: label })).toBeVisible()})diff --git a/e2e/features/support/hooks.ts b/e2e/features/support/hooks.tsindex a6862d79f54..9e8c025ef83 100644--- a/e2e/features/support/hooks.ts+++ b/e2e/features/support/hooks.ts@@ -46,7 +46,11 @@ BeforeAll(async () => {Before(async function (this: DifyWorld, { pickle }) {if (!browser) throw new Error('Shared Playwright browser is not available.')- await this.startAuthenticatedSession(browser)+ const isUnauthenticatedScenario = pickle.tags.some((tag) => tag.name === '@unauthenticated')++ if (isUnauthenticatedScenario) await this.startUnauthenticatedSession(browser)+ else await this.startAuthenticatedSession(browser)+this.scenarioStartedAt = Date.now()const tags = pickle.tags.map((tag) => tag.name).join(' ')diff --git a/e2e/features/support/world.ts b/e2e/features/support/world.tsindex 15ab8daf168..bf631991075 100644--- a/e2e/features/support/world.ts+++ b/e2e/features/support/world.ts@@ -25,12 +25,12 @@ export class DifyWorld extends World {this.pageErrors = []}- async startAuthenticatedSession(browser: Browser) {+ async startSession(browser: Browser, authenticated: boolean) {this.resetScenarioState()this.context = await browser.newContext({baseURL,locale: defaultLocale,- storageState: authStatePath,+ ...(authenticated ? { storageState: authStatePath } : {}),})this.context.setDefaultTimeout(30_000)this.page = await this.context.newPage()@@ -44,6 +44,14 @@ export class DifyWorld extends World {})}+ async startAuthenticatedSession(browser: Browser) {+ await this.startSession(browser, true)+ }++ async startUnauthenticatedSession(browser: Browser) {+ await this.startSession(browser, false)+ }+getPage() {if (!this.page) throw new Error('Playwright page has not been initialized for this scenario.')diff --git a/web/service/fetch.ts b/web/service/fetch.tsindex 1d92c0c62f1..74ee7a96143 100644--- a/web/service/fetch.ts+++ b/web/service/fetch.ts@@ -38,6 +38,26 @@ export type ResponseError = {status: number}+const createResponseFromHTTPError = (error: HTTPError): Response => {+ const headers = new Headers(error.response.headers)+ headers.delete('content-length')++ let body: BodyInit | null = null+ if (typeof error.data === 'string')+ body = error.data+ else if (error.data !== undefined)+ body = JSON.stringify(error.data)++ if (body !== null && !headers.has('content-type'))+ headers.set('content-type', ContentType.json)++ return new Response(body, {+ status: error.response.status,+ statusText: error.response.statusText,+ headers,+ })+}+const afterResponseErrorCode = (otherOptions: IOtherOptions): AfterResponseHook => {return async ({ response }) => {if (!/^([23])\d{2}$/.test(String(response.status))) {@@ -209,7 +229,7 @@ async function base<T>(url: string, options: FetchOptionType = {}, otherOptions:}catch (error) {if (error instanceof HTTPError)- throw error.response.clone()+ throw createResponseFromHTTPError(error)throw error}