Skip to content
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
7 changes: 7 additions & 0 deletions .changeset/whole-pumas-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@workflow/web-shared": patch
"@workflow/errors": patch
"@workflow/cli": patch
---

Move auth error messages into @workflow/errors package
4 changes: 2 additions & 2 deletions packages/cli/src/commands/inspect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Args, Flags } from '@oclif/core';
import { VERCEL_403_ERROR_MESSAGE } from '@workflow/errors';
import { BaseCommand } from '../base.js';
import { LOGGING_CONFIG, logger } from '../lib/config/log.js';
import type { InspectCLIOptions } from '../lib/config/types.js';
Expand Down Expand Up @@ -35,8 +36,7 @@ export default class Inspect extends BaseCommand {
async catch(error: any) {
// Check if this is a 403 error from the Vercel backend
if (error?.status === 403) {
const message =
'Your current vercel account does not have access to this workflow run. Please use `vercel login` to login, or use `vercel switch` to ensure you can access the correct team.';
const message = VERCEL_403_ERROR_MESSAGE;
logger.error(message);
} else if (LOGGING_CONFIG.VERBOSE_MODE) {
logger.error(error);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Args } from '@oclif/core';
import { VERCEL_403_ERROR_MESSAGE } from '@workflow/errors';
import { BaseCommand } from '../base.js';
import { LOGGING_CONFIG, logger } from '../lib/config/log.js';
import { cliFlags } from '../lib/inspect/flags.js';
Expand All @@ -19,8 +20,7 @@ export default class Web extends BaseCommand {
async catch(error: any) {
// Check if this is a 403 error from the Vercel backend
if (error?.status === 403) {
const message =
'Your current vercel account does not have access to this workflow run. Please use `vercel login` to login, or use `vercel switch` to ensure you can access the correct team.';
const message = VERCEL_403_ERROR_MESSAGE;
logger.error(message);
} else if (LOGGING_CONFIG.VERBOSE_MODE) {
logger.error(error);
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/src/lib/inspect/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getDeserializeStream,
getExternalRevivers,
} from '@workflow/core/serialization';
import { VERCEL_403_ERROR_MESSAGE } from '@workflow/errors';
import type {
Event,
Hook,
Expand Down Expand Up @@ -139,9 +140,7 @@ const checkAndHandleVercelAccessError = (
if (backend === 'vercel' && error && typeof error === 'object') {
const err = error as Record<string, unknown>;
if (err.status === 403) {
logger.error(
'Your current vercel account does not have access to this workflow run. Please use `vercel login` to login, or use `vercel switch` to ensure you can access the correct team.'
);
logger.error(VERCEL_403_ERROR_MESSAGE);
return true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/errors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,6 @@ export class RetryableError extends Error {
return isError(value) && value.name === 'RetryableError';
}
}

export const VERCEL_403_ERROR_MESSAGE =
'Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account. You might need to run `vercel env pull` to use the latest environment variables.';
3 changes: 2 additions & 1 deletion packages/web-shared/src/api/workflow-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { VERCEL_403_ERROR_MESSAGE } from '@workflow/errors';
import type {
Event,
Hook,
Expand Down Expand Up @@ -55,7 +56,7 @@ export const getErrorMessage = (error: Error | WorkflowWebAPIError): string => {
if ('layer' in error && error.layer) {
if (error instanceof WorkflowWebAPIError) {
if (error.request?.status === 403) {
return 'Your current Vercel account does not have access to this data. Please use `vercel login` to log in, or use `vercel switch` to ensure you can access the correct team.';
return VERCEL_403_ERROR_MESSAGE;
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/web-shared/src/stream-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Chunk {
export function StreamViewer({ env, streamId }: StreamViewerProps) {
const [chunks, setChunks] = useState<Chunk[]>([]);
const [isLive, setIsLive] = useState(true);
// TODO: Handle 410 error specifically (stream expired)
const [error, setError] = useState<string | null>(null);
const [hasMoreBelow, setHasMoreBelow] = useState(false);
const scrollRef = useRef<HTMLDivElement>(null);
Expand Down
23 changes: 2 additions & 21 deletions workbench/nextjs-turbopack/app/api/workflows/stream/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,8 @@ export async function POST(request: NextRequest) {
);
}

// Get the stream if the run has a stream method
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const runObj = run as any;
let stream: ReadableStream | null = null;
if (typeof runObj.stream === 'function') {
try {
stream = runObj.stream();
} catch (error) {
console.error('Error calling run.stream():', error);
}
}

if (!stream) {
return NextResponse.json(
{ error: 'Stream not available for this run' },
{ status: 404 }
);
}

// Create a response with the stream
return new Response(stream, {
const readable = run.getReadable();
return new Response(readable, {
headers: {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Expand Down
Loading