Skip to content

Commit b943c41

Browse files
committed
fix(obsidian): validateConfig must check authenticated field, not just status
GET / is the only public endpoint per the Local REST API spec — it returns 200 regardless of auth and exposes the real signal via response.authenticated. The prior status-based check let invalid API keys pass validation.
1 parent 4e852c5 commit b943c41

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

apps/sim/connectors/obsidian/obsidian.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,23 @@ export const obsidianConnector: ConnectorConfig = {
313313
VALIDATE_RETRY_OPTIONS
314314
)
315315

316-
if (response.status === 401 || response.status === 403) {
316+
if (!response.ok) {
317+
return { valid: false, error: `Obsidian API returned status ${response.status}` }
318+
}
319+
320+
/**
321+
* `GET /` is the only public endpoint and returns 200 regardless of auth;
322+
* the response body's `authenticated` field is the actual auth signal.
323+
* See https://coddingtonbear.github.io/obsidian-local-rest-api/.
324+
*/
325+
const data = (await response.json()) as { authenticated?: boolean }
326+
if (!data?.authenticated) {
317327
return {
318328
valid: false,
319329
error: 'Invalid API key — check your Obsidian Local REST API settings',
320330
}
321331
}
322332

323-
if (!response.ok) {
324-
return { valid: false, error: `Obsidian API returned status ${response.status}` }
325-
}
326-
327333
const folderPath = (sourceConfig.folderPath as string) || ''
328334
if (folderPath.trim()) {
329335
const entries = await listDirectory(

0 commit comments

Comments
 (0)