Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
5f4dc19
fix(sidebar): pluralize the Knowledge bases nav label (#6514)
j15z Aug 11, 2026
4bafd14
improvement(provenance): name every guard that can latch a registry (…
icecrasher321 Aug 11, 2026
4d37572
fix(knowledge): pluralize the module header and root breadcrumb (#6516)
j15z Aug 11, 2026
c5db403
feat(comparisons): add code-sandbox and session-policy rows (#6517)
waleedlatif1 Aug 11, 2026
fff6606
fix(folders): show the folder trail in table and knowledge base heade…
waleedlatif1 Aug 11, 2026
f5c06d4
fix(tables): handle row deletion during cell execution (#6520)
TheodoreSpeaks Aug 11, 2026
245ad1b
feat(workflows): new workflow block card, progress indicator, colors,…
icecrasher321 Aug 11, 2026
ba5dfb1
feat(salesforce): add JWT bearer flow and sandbox OAuth support (#6508)
waleedlatif1 Aug 11, 2026
507def6
fix(workflows): port the canvas card icons off lucide-react (#6523)
icecrasher321 Aug 11, 2026
daac4f3
docs(salesforce): correct the setup steps that would strand an admin …
waleedlatif1 Aug 11, 2026
5478a69
improvement(setup): complete knowledge and update flows (#6521)
TheodoreSpeaks Aug 11, 2026
ff64389
fix(logs): keep run provenance when compaction drops the execution st…
waleedlatif1 Aug 11, 2026
1a39e29
fix(chat): stop the streaming transcript floor inventing scroll space…
waleedlatif1 Aug 11, 2026
a64ce49
feat(incidentio): add on-call, alert, catalog, and team tools (#6529)
waleedlatif1 Aug 11, 2026
1551923
fix(chat): stop losing sends aborted during mount-settling (#6525)
j15z Aug 11, 2026
2f43148
improvement(ui): align terminal with the workflow design system, fix …
waleedlatif1 Aug 11, 2026
9277e7d
feat(search): page-aware cmd+k palette with ask-Sim mode (#6518)
j15z Aug 11, 2026
263e3ca
improvement(external-endpoints): v2 versions with clean signatures + …
icecrasher321 Aug 11, 2026
7c75061
fix(ci): include auth package in app prune (#6538)
TheodoreSpeaks Aug 11, 2026
783e1b5
fix(executor): restore delegated workflow execution (#6539)
TheodoreSpeaks Aug 11, 2026
f8644cc
fix(chat): deduplicate chat sends server-side instead of probing for …
waleedlatif1 Aug 11, 2026
ff378fa
fix(knowledge): retain model input provenance (#6540)
TheodoreSpeaks Aug 11, 2026
71ea7e5
fix(cmdk): New Chat -> New chat (#6543)
j15z Aug 11, 2026
6fdb145
fix(v2-api): standardization (#6542)
waleedlatif1 Aug 11, 2026
fee45e2
fix(atlassian): share one cached, retrying cloudId resolver across Ji…
waleedlatif1 Aug 11, 2026
2f1bb5a
fix(cmdk): update search-modal assertions to the renamed New chat lab…
waleedlatif1 Aug 11, 2026
c365b14
feat(calendly): extend tools with booking, availability, no-shows, an…
waleedlatif1 Aug 11, 2026
bf82512
fix(auth): let Microsoft sign-in link via Entra's domain-verified ema…
waleedlatif1 Aug 11, 2026
df052ac
fix(tools): bound internal tool calls by the plan deadline, not Bun's…
icecrasher321 Aug 11, 2026
440a68b
improvement(audits): skip the sql-date-binding parse for files withou…
waleedlatif1 Aug 11, 2026
061ecd3
fix(api): restore legacy endpoint compatibility (#6552)
TheodoreSpeaks Aug 11, 2026
31bfcdd
fix(auth): rate limit the password reset endpoints (#6553)
waleedlatif1 Aug 11, 2026
596bf4f
feat(library): What Is Retrieval-Augmented Generation (RAG)? (#6555)
icecrasher321 Aug 11, 2026
b879960
fix(provenance): make one length floor the whole substitution rule (#…
icecrasher321 Aug 11, 2026
bd91ab7
fix(files): restore horizontal scroll in CSV and XLSX preview tables …
waleedlatif1 Aug 11, 2026
81e04a8
fix(agiloft): align the integration with the documented ewws REST int…
waleedlatif1 Aug 11, 2026
ae1f62d
improvement(provenance): make the incompleteness reason set closed an…
icecrasher321 Aug 11, 2026
d6505f6
feat(blog): Tracking Secrets Through an Agent Run (#6558)
icecrasher321 Aug 11, 2026
6d3e484
fix(api): align v2 permissions and resource behavior (#6557)
TheodoreSpeaks Aug 11, 2026
1dd85eb
improvement(desktop): add apple signing, fix some bugs (#6519)
Sg312 Aug 11, 2026
e31d2a9
fix(files): let a mouse wheel scroll CSV and XLSX previews horizontal…
waleedlatif1 Aug 11, 2026
ec8b988
fix(forks): detect secrets referenced from advanced-mode fields (#6566)
icecrasher321 Aug 11, 2026
be5db68
fix(agiloft): repoint the block at the alrest surface and fix EWLogin…
waleedlatif1 Aug 11, 2026
3595fa2
fix(credentials): authorize shared credentials without requiring a wo…
waleedlatif1 Aug 11, 2026
9b9f4ee
fix(v2-api): close three secret disclosures, make the surface consist…
waleedlatif1 Aug 11, 2026
05de463
fix(agiloft): resolve attachment MIME type instead of trusting the he…
waleedlatif1 Aug 12, 2026
cb28090
fix(mship, desktop): fix bugs (#6572)
Sg312 Aug 12, 2026
092311e
fix(api): restore migrated endpoint and SDK compatibility (#6564)
TheodoreSpeaks Aug 12, 2026
e7590c8
improvement(desktop): help menu
Sg312 Aug 12, 2026
7f39678
improvement(desktop, executions): fix desktop update script and throw…
Sg312 Aug 12, 2026
2a5e29a
improvement(updates): validate update path and fix native mac help (#…
Sg312 Aug 12, 2026
9f3c202
fix(tables): cap row pages and use native cursors (#6582)
TheodoreSpeaks Aug 12, 2026
1874cec
fix(api): collapse the internal error envelope and restore requestId …
waleedlatif1 Aug 12, 2026
261435c
fix(authz): enforce credential and workspace boundaries (#6585)
icecrasher321 Aug 12, 2026
7c05e36
fix(api): close five defects found auditing the v2 migration against …
waleedlatif1 Aug 12, 2026
a72457b
fix(docs): preserve items response fields (#6587)
j15z Aug 12, 2026
5e1862e
fix(tables): preserve group auto-run semantics (#6579)
TheodoreSpeaks Aug 12, 2026
083319b
fix(api): conceal cross-tenant resource denials on internal routes (#…
waleedlatif1 Aug 12, 2026
766526b
fix(logs): restore narrow v1 detail query (#6588)
TheodoreSpeaks Aug 12, 2026
f306b51
fix(files): preserve slashes in folder paths (#6589)
TheodoreSpeaks Aug 12, 2026
23318a1
fix(security): redact workflow snapshot secrets (#6581)
TheodoreSpeaks Aug 12, 2026
380aca2
fix(desktop): fix background tab spawning (#6590)
Sg312 Aug 12, 2026
91f31a4
fix(api): wait for knowledge dispatch and encode filenames (#6583)
TheodoreSpeaks Aug 12, 2026
a1a05c6
fix(api): widen the cancel-execution reason contract to what the rout…
waleedlatif1 Aug 12, 2026
a61cbf7
fix(tools): bind schema-enrichment reads to executor delegations (#6593)
waleedlatif1 Aug 12, 2026
eb26b42
fix(logs, workflows): snapshot fetch optionality, restore consistent …
icecrasher321 Aug 12, 2026
9923faf
fix(tables): prevent legacy group auto-run dispatch (#6595)
TheodoreSpeaks Aug 12, 2026
50e5dff
fix(workflows): redact run and export secrets (#6591)
TheodoreSpeaks Aug 12, 2026
326cb94
fix(knowledge): return pending status for new documents (#6597)
TheodoreSpeaks Aug 12, 2026
933eea5
fix(mcp): audit the columns an MCP server update wrote, not the param…
waleedlatif1 Aug 12, 2026
22b3569
fix(files): order file folders in SQL like every other folder list (#…
waleedlatif1 Aug 12, 2026
0877ecb
fix(tables): tolerate row deletion during run cancellation (#6600)
TheodoreSpeaks Aug 12, 2026
a6ebfec
fix(files): restore CSV preview cancellation (#6596)
icecrasher321 Aug 12, 2026
0d640aa
fix(uploads): make execution attachment completion replay-safe (#6601)
waleedlatif1 Aug 12, 2026
e65345b
test(table): pin the executor auth pairing on the table read route (#…
waleedlatif1 Aug 12, 2026
a40e379
chore: remove the stray .agiloft-spec working notes (#6605)
waleedlatif1 Aug 12, 2026
068422b
refactor(audit): derive updatedFields through one shared helper (#6604)
waleedlatif1 Aug 12, 2026
b5d9e93
fix(mcp): audit an upsert that rewrites or revives a server (#6602)
waleedlatif1 Aug 12, 2026
892401a
fix(uploads): sign Azure upload URLs create-only (#6607)
waleedlatif1 Aug 12, 2026
d1bc99a
improvement(integrations): add Managed Agents templates and guard doc…
waleedlatif1 Aug 12, 2026
d96f3f9
perf(db): drop 0287's two zero-row scans from the ACCESS EXCLUSIVE ho…
waleedlatif1 Aug 12, 2026
d60b6c6
fix(mcp): stop refusing tool results authored by another workspace me…
waleedlatif1 Aug 12, 2026
8f85ded
fix(workflows): pin a stored block retry policy when loading it (#6614)
waleedlatif1 Aug 12, 2026
b33f8e8
fix(executor): give the workflow agent tool the caller's env and PII …
waleedlatif1 Aug 12, 2026
5a63eb8
fix(copilot): clamp the legacy int4 size when materializing a chat up…
waleedlatif1 Aug 12, 2026
34d65df
fix(sdk): make the 0.2.0 SDK release safe to publish (#6616)
waleedlatif1 Aug 12, 2026
47f1430
fix(docs): restore api-reference URL continuity and fix translated SD…
waleedlatif1 Aug 12, 2026
366829b
fix(v2): derive the log and run status enums from the persisted statu…
waleedlatif1 Aug 12, 2026
2054947
test(export): pin the table and tool-param loss the sanitized export …
waleedlatif1 Aug 12, 2026
082deb2
fix(executor): copy the env map at the workflow-tool boundary (#6618)
waleedlatif1 Aug 12, 2026
7b3e6a6
fix(executor): carry child provenance across the workflow agent tool …
waleedlatif1 Aug 12, 2026
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
Prev Previous commit
Next Next commit
fix(api): align v2 permissions and resource behavior (#6557)
* fix(api): align v2 permissions and resource behavior

* fix(api): refine resource authorization boundaries

* fix(tables): restore large durable imports

* fix(files): classify missing archive targets
  • Loading branch information
TheodoreSpeaks authored Aug 11, 2026
commit 6d3e484fb3142a721447fef03cc2fb634c55dc39
2 changes: 1 addition & 1 deletion apps/docs/openapi-v2-tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -7017,7 +7017,7 @@
"size": {
"type": "integer",
"minimum": 1,
"maximum": 26214400,
"maximum": 5368709120,
"description": "Exact CSV file size in bytes."
}
},
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/app/api/table/[tableId]/import/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { statusForOrchestrationError } from '@/lib/core/orchestration/types'
import { isMultipartError, readMultipart } from '@/lib/core/utils/multipart'
import { generateRequestId } from '@/lib/core/utils/request'
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
import { CSV_MAX_FILE_SIZE_BYTES, type CsvHeaderMapping } from '@/lib/table'
import { CSV_SYNC_MAX_FILE_SIZE_BYTES, type CsvHeaderMapping } from '@/lib/table'
import { performTableCsvImport } from '@/lib/table/orchestration'
import { getUserSettings } from '@/lib/users/queries'
import {
Expand Down Expand Up @@ -53,7 +53,7 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro
let parsed: Awaited<ReturnType<typeof readMultipart>>
try {
parsed = await readMultipart(request, {
maxFileBytes: CSV_MAX_FILE_SIZE_BYTES,
maxFileBytes: CSV_SYNC_MAX_FILE_SIZE_BYTES,
requiredFieldsBeforeFile: ['workspaceId'],
signal: request.signal,
})
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/app/api/table/import-csv/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isMultipartError, readMultipart } from '@/lib/core/utils/multipart'
import { generateRequestId } from '@/lib/core/utils/request'
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
import { findActiveFolder } from '@/lib/folders/queries'
import { CSV_MAX_FILE_SIZE_BYTES } from '@/lib/table'
import { CSV_SYNC_MAX_FILE_SIZE_BYTES } from '@/lib/table'
import { performCreateTableFromCsv } from '@/lib/table/orchestration'
import { getUserSettings } from '@/lib/users/queries'
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
Expand Down Expand Up @@ -39,7 +39,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
let parsed: Awaited<ReturnType<typeof readMultipart>>
try {
parsed = await readMultipart(request, {
maxFileBytes: CSV_MAX_FILE_SIZE_BYTES,
maxFileBytes: CSV_SYNC_MAX_FILE_SIZE_BYTES,
requiredFieldsBeforeFile: ['workspaceId'],
signal: request.signal,
})
Expand Down
15 changes: 15 additions & 0 deletions apps/sim/app/api/v2/custom-tools/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
import { NextRequest } from 'next/server'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
InsufficientWorkspacePermissionsError,
NoWorkspaceAccessError,
} from '@/lib/core/application'

const { mocks, MockV2ApiKeyUnauthenticatedError } = vi.hoisted(() => {
class MockV2ApiKeyUnauthenticatedError extends Error {}
Expand Down Expand Up @@ -160,4 +164,15 @@ describe('/api/v2/custom-tools/[id]', () => {
expect(response.status).toBe(401)
expect(mocks.update).not.toHaveBeenCalled()
})

it('conceals cross-tenant access while preserving same-workspace role denials', async () => {
mocks.get.mockRejectedValueOnce(new NoWorkspaceAccessError())
expect((await GET(request('GET'), context)).status).toBe(404)

mocks.update.mockRejectedValueOnce(new InsufficientWorkspacePermissionsError())
expect(
(await PATCH(request('PATCH', { workspaceId: WORKSPACE_ID, code: 'return 2' }), context))
.status
).toBe(403)
})
})
12 changes: 8 additions & 4 deletions apps/sim/app/api/v2/custom-tools/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
v2UpdateCustomToolContract,
} from '@/lib/api/contracts/v2/custom-tools'
import {
createV2ResourceConcealmentPolicy,
defineV2JsonRoute,
v2ApiKeyAuth,
v2OrchestrationErrorPolicy,
v2RateLimits,
} from '@/lib/api/server/routes'
import { customToolOperations } from '@/lib/custom-tools/application/operations'
Expand All @@ -20,13 +20,17 @@ import { toV2CustomTool } from '@/app/api/v2/custom-tools/utils'
export const dynamic = 'force-dynamic'
export const revalidate = 0

const customToolResourceErrorPolicy = createV2ResourceConcealmentPolicy({
notFoundMessage: 'Custom tool not found',
})

/** GET /api/v2/custom-tools/[id] — Fetch a single custom tool. */
export const GET = defineV2JsonRoute({
contract: v2GetCustomToolContract,
operation: customToolOperations.read,
auth: v2ApiKeyAuth,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2OrchestrationErrorPolicy,
errorPolicy: customToolResourceErrorPolicy,
mapInput: ({ params, query }) => ({ workspaceId: query.workspaceId, toolId: params.id }),
useCase: getWorkspaceCustomToolUseCase,
present: ({ tool }) => ({ data: { customTool: toV2CustomTool(tool) } }),
Expand All @@ -38,7 +42,7 @@ export const PATCH = defineV2JsonRoute({
operation: customToolOperations.update,
auth: v2ApiKeyAuth,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2OrchestrationErrorPolicy,
errorPolicy: customToolResourceErrorPolicy,
mapInput: ({ params, body }) => ({
...body,
toolId: params.id,
Expand All @@ -54,7 +58,7 @@ export const DELETE = defineV2JsonRoute({
operation: customToolOperations.delete,
auth: v2ApiKeyAuth,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2OrchestrationErrorPolicy,
errorPolicy: customToolResourceErrorPolicy,
mapInput: ({ params, query }) => ({
workspaceId: query.workspaceId,
toolId: params.id,
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/app/api/v2/files/[fileId]/metadata/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('GET /api/v2/files/[fileId]/metadata', () => {
expect(mocks.readMetadata).not.toHaveBeenCalled()
})

it('conceals an authorization failure as not found', async () => {
it('conceals cross-workspace authorization as not found', async () => {
mocks.readMetadata.mockRejectedValue(new NoWorkspaceAccessError())

const response = await callGet(`workspaceId=${WORKSPACE_ID}`)
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/app/api/v2/files/[fileId]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('v2 single-file routes', () => {
})
})

it('conceals download authorization failures', async () => {
it('conceals cross-workspace download authorization', async () => {
mocks.download.mockRejectedValue(new NoWorkspaceAccessError())

const response = await GET(
Expand Down
12 changes: 7 additions & 5 deletions apps/sim/app/api/v2/files/uploads/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ function uploadStatus(status: string): V2UploadStatus {

import type { Principal } from '@sim/auth/principal'
import type { NextRequest, NextResponse } from 'next/server'
import { createV2ResourceConcealmentPolicy } from '@/lib/api/server/routes'
import { authenticateV2ApiKey } from '@/lib/api/server/routes/v2-api-key-auth'
import { v2CaughtOrchestrationError, v2Error } from '@/app/api/v2/lib/response'

const uploadControlErrorPolicy = createV2ResourceConcealmentPolicy({
notFoundMessage: 'Upload session not found',
})

/** Re-authenticates the API key for each upload control leg. */
export async function authenticateUploadPrincipal(request: NextRequest): Promise<Principal> {
const auth = await authenticateV2ApiKey(request.headers.get('x-api-key'))
return auth.principal
}

/** Resource-ID upload controls conceal authorization failures as absence. */
/** Conceals cross-tenant upload-session authorization while preserving same-workspace denials. */
export function v2UploadControlError(error: unknown): NextResponse | null {
const response = v2CaughtOrchestrationError(error)
if (!response) return null
return response.status === 403 ? v2Error('NOT_FOUND', 'Upload session not found') : response
return uploadControlErrorPolicy.render(error)
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const DELETE = defineV2JsonRoute({
auth: v2ApiKeyAuth,
operation: knowledgeOperations.deleteDocument,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2KnowledgeErrorPolicies.default,
errorPolicy: v2KnowledgeErrorPolicies.concealKnowledgeBaseAuthorization,
mapInput: ({ params, query }) => ({
knowledgeBaseId: params.id,
documentId: params.documentId,
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/app/api/v2/knowledge/[id]/documents/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const POST = defineV2BodyLifecycleRoute({
auth: v2ApiKeyAuth,
operation: knowledgeOperations.uploadDocument,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2KnowledgeErrorPolicies.documentUpload,
errorPolicy: v2KnowledgeErrorPolicies.concealKnowledgeBaseUploadAuthorization,
admission: {
mapInput: ({ params, query }) => ({
knowledgeBaseId: params.id,
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/app/api/v2/knowledge/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const PATCH = defineV2JsonRoute({
auth: v2ApiKeyAuth,
operation: knowledgeOperations.update,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2KnowledgeErrorPolicies.default,
errorPolicy: v2KnowledgeErrorPolicies.concealKnowledgeBaseAuthorization,
parseOptions: {
invalidJsonResponse: () => v2Error('BAD_REQUEST', 'Request body must be valid JSON'),
},
Expand All @@ -66,7 +66,7 @@ export const DELETE = defineV2JsonRoute({
auth: v2ApiKeyAuth,
operation: knowledgeOperations.delete,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2KnowledgeErrorPolicies.default,
errorPolicy: v2KnowledgeErrorPolicies.concealKnowledgeBaseAuthorization,
mapInput: ({ params, query }) => ({
knowledgeBaseId: params.id,
assertedWorkspaceId: query.workspaceId,
Expand Down
4 changes: 3 additions & 1 deletion apps/sim/app/api/v2/knowledge/search/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ describe('POST /api/v2/knowledge/search', () => {
})
})

it('delegates normalized IDs through the semantic operation', async () => {
it('delegates normalized IDs and the selected search mode through the semantic operation', async () => {
const request = buildRequest(
JSON.stringify({
workspaceId: WORKSPACE_ID,
knowledgeBaseIds: 'kb-1',
query: 'hello',
topK: 10,
searchMode: 'hybrid',
})
)

Expand All @@ -91,6 +92,7 @@ describe('POST /api/v2/knowledge/search', () => {
query: 'hello',
topK: 10,
tagFilters: undefined,
searchMode: 'hybrid',
},
request,
})
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/app/api/v2/knowledge/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const POST = defineV2JsonRoute({
auth: v2ApiKeyAuth,
operation: knowledgeOperations.search,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2KnowledgeErrorPolicies.usage,
errorPolicy: v2KnowledgeErrorPolicies.concealKnowledgeBaseUsageAuthorization,
parseOptions: {
invalidJsonResponse: () => v2Error('BAD_REQUEST', 'Request body must be valid JSON'),
},
Expand All @@ -26,6 +26,7 @@ export const POST = defineV2JsonRoute({
query: body.query,
topK: body.topK,
tagFilters: body.tagFilters,
searchMode: body.searchMode,
}),
useCase: searchKnowledge,
present: (result) => ({ data: result }),
Expand Down
6 changes: 2 additions & 4 deletions apps/sim/app/api/v2/logs/[runId]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ vi.mock('@/lib/logs/application/get-public-log', () => ({
getPublicLog: { operation: { id: 'logs.read_detail' }, execute: mocks.execute },
}))

import { OrchestrationError } from '@/lib/core/orchestration/types'
import { NoWorkspaceAccessError } from '@/lib/core/application'
import { GET } from '@/app/api/v2/logs/[runId]/route'

const auth = {
Expand Down Expand Up @@ -95,9 +95,7 @@ describe('GET /api/v2/logs/[runId]', () => {
})

it('conceals canonical workspace authorization as log not-found', async () => {
mocks.execute.mockRejectedValueOnce(
new OrchestrationError('forbidden', 'Workspace API key cannot perform this operation')
)
mocks.execute.mockRejectedValueOnce(new NoWorkspaceAccessError())

const response = await GET(new NextRequest('http://localhost:3000/api/v2/logs/run-1'), {
params: Promise.resolve({ runId: 'run-1' }),
Expand Down
15 changes: 15 additions & 0 deletions apps/sim/app/api/v2/mcp-servers/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import type { mcpServers } from '@sim/db/schema'
import { NextRequest } from 'next/server'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
InsufficientWorkspacePermissionsError,
NoWorkspaceAccessError,
} from '@/lib/core/application'

const { mocks, MockV2ApiKeyUnauthenticatedError } = vi.hoisted(() => {
class MockV2ApiKeyUnauthenticatedError extends Error {}
Expand Down Expand Up @@ -178,4 +182,15 @@ describe('/api/v2/mcp-servers/[id]', () => {
expect(response.status).toBe(401)
expect(mocks.update).not.toHaveBeenCalled()
})

it('conceals cross-tenant access while preserving same-workspace role denials', async () => {
mocks.get.mockRejectedValueOnce(new NoWorkspaceAccessError())
expect((await GET(request('GET'), context)).status).toBe(404)

mocks.update.mockRejectedValueOnce(new InsufficientWorkspacePermissionsError())
expect(
(await PATCH(request('PATCH', { workspaceId: WORKSPACE_ID, name: 'New docs' }), context))
.status
).toBe(403)
})
})
12 changes: 8 additions & 4 deletions apps/sim/app/api/v2/mcp-servers/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
v2UpdateMcpServerContract,
} from '@/lib/api/contracts/v2/mcp-servers'
import {
createV2ResourceConcealmentPolicy,
defineV2JsonRoute,
v2ApiKeyAuth,
v2OrchestrationErrorPolicy,
v2RateLimits,
} from '@/lib/api/server/routes'
import { mcpServerOperations } from '@/lib/mcp/application/operations'
Expand All @@ -21,13 +21,17 @@ import { toV2McpServer } from '@/app/api/v2/mcp-servers/utils'
export const dynamic = 'force-dynamic'
export const revalidate = 0

const mcpServerResourceErrorPolicy = createV2ResourceConcealmentPolicy({
notFoundMessage: 'MCP server not found',
})

/** GET /api/v2/mcp-servers/[id] — Fetch a single MCP server. */
export const GET = defineV2JsonRoute({
contract: v2GetMcpServerContract,
operation: mcpServerOperations.read,
auth: v2ApiKeyAuth,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2OrchestrationErrorPolicy,
errorPolicy: mcpServerResourceErrorPolicy,
mapInput: ({ params, query }) => ({ workspaceId: query.workspaceId, serverId: params.id }),
useCase: getMcpServerUseCase,
present: ({ server }) => ({ data: { mcpServer: toV2McpServer(server) } }),
Expand All @@ -39,7 +43,7 @@ export const PATCH = defineV2JsonRoute({
operation: mcpServerOperations.update,
auth: v2ApiKeyAuth,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2OrchestrationErrorPolicy,
errorPolicy: mcpServerResourceErrorPolicy,
mapInput: ({ params, body }) => ({ ...body, serverId: params.id, source: 'api' as const }),
useCase: updateMcpServerUseCase,
present: ({ server }) => ({ data: { mcpServer: toV2McpServer(server) } }),
Expand All @@ -51,7 +55,7 @@ export const DELETE = defineV2JsonRoute({
operation: mcpServerOperations.delete,
auth: v2ApiKeyAuth,
rateLimit: v2RateLimits.publicApi,
errorPolicy: v2OrchestrationErrorPolicy,
errorPolicy: mcpServerResourceErrorPolicy,
mapInput: ({ params, query }) => ({
workspaceId: query.workspaceId,
serverId: params.id,
Expand Down
15 changes: 15 additions & 0 deletions apps/sim/app/api/v2/skills/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
import { NextRequest } from 'next/server'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
InsufficientWorkspacePermissionsError,
NoWorkspaceAccessError,
} from '@/lib/core/application'

const { mocks, MockV2ApiKeyUnauthenticatedError } = vi.hoisted(() => {
class MockV2ApiKeyUnauthenticatedError extends Error {}
Expand Down Expand Up @@ -165,4 +169,15 @@ describe('/api/v2/skills/[id]', () => {
expect(response.status).toBe(401)
expect(mocks.update).not.toHaveBeenCalled()
})

it('conceals cross-tenant access while preserving same-workspace role denials', async () => {
mocks.get.mockRejectedValueOnce(new NoWorkspaceAccessError())
expect((await GET(request('GET'), context)).status).toBe(404)

mocks.update.mockRejectedValueOnce(new InsufficientWorkspacePermissionsError())
expect(
(await PATCH(request('PATCH', { workspaceId: WORKSPACE_ID, content: '# Updated' }), context))
.status
).toBe(403)
})
})
Loading
Loading