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
8 changes: 6 additions & 2 deletions client/packages/cli/src/commands/info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClientResponse } from '@effect/platform';
import { Effect, Schema, Option } from 'effect';
import { InstantHttpAuthed } from '../lib/http.ts';
import { getBaseUrl, InstantHttpAuthed } from '../lib/http.ts';
import { version } from '@instantdb/version';
import { CurrentApp } from '../context/currentApp.ts';

Expand All @@ -21,6 +21,7 @@ export const DashAppResponse = Schema.Struct({

export const infoCommand = () =>
Effect.gen(function* () {
const baseUrl = yield* getBaseUrl;
const authedHttp = yield* Effect.serviceOption(InstantHttpAuthed).pipe(
Effect.map(Option.getOrNull),
);
Expand All @@ -32,7 +33,10 @@ export const infoCommand = () =>
const meData = yield* authedHttp.get('/dash/me').pipe(
Effect.flatMap(HttpClientResponse.schemaBodyJson(DashMeResponse)),
Effect.mapError(
(e) => new Error("Couldn't get user information.", { cause: e }),
(e) =>
new Error(`Couldn't get user information (${baseUrl}).`, {
Comment thread
drew-harris marked this conversation as resolved.
cause: e,
}),
Comment on lines +36 to +39

@coderabbitai coderabbitai Bot Jul 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply URL context to the app fetch as well.

This mapError only covers /dash/me; the later /dash/apps/... request can still fail without the resolved dashboard URL, especially for schema or non-InstantHttpError failures. Reuse the same error mapping for both dashboard requests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@client/packages/cli/src/commands/info.ts` around lines 36 - 39, Reuse the
existing mapError logic that adds the resolved dashboard URL context for the
later `/dash/apps/...` request as well as the `/dash/me` request. Update the
app-fetch error handling near the dashboard request so schema and
non-InstantHttpError failures are wrapped consistently, without changing
successful responses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the later /dash/apps request can fail but ti will fail as an InstantHttpError which will print the url.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline client/packages/cli/src/layer.ts --items all
printf '\n--- InstantHttpError definitions and relevant usage ---\n'
rg -n -C 5 '\bInstantHttpError\b|\bInstantHTTPError\b|function printRedErrors|const printRedErrors|printRedErrors\s*=' client/packages/cli/src
printf '\n--- info command request/error handling ---\n'
sed -n '20,65p' client/packages/cli/src/commands/info.ts

Length of output: 9912


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- InstantHttpError printer ---'
sed -n '70,110p' client/packages/cli/src/layer.ts
printf '%s\n' '--- HTTP client status-error transformation ---'
sed -n '45,125p' client/packages/cli/src/lib/http.ts
printf '%s\n' '--- Existing dashboard schema error wrappers ---'
rg -n -C 4 'schemaBodyJson\(Dash(App|Me)Response\)|Couldn.t get (user|app) information' client/packages/cli/src

Length of output: 6750


@drew-harris, verified: non-2xx responses do become InstantHttpError, so that path is covered.

The remaining case is a 2xx response that fails schemaBodyJson(DashAppResponse)—for example, malformed JSON or a response that no longer matches the expected dashboard schema. That failure occurs after filterStatusOk and is not an InstantHttpError, so it will not have methodAndUrl.

So the requested wrapping is only needed for that decode-error path; the HTTP-error path is already handled as you described.

You are interacting with an AI system.

Comment on lines +36 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Redact sensitive URL components before logging.

baseUrl may come directly from INSTANT_CLI_API_URI, so interpolating it verbatim can expose embedded credentials or token-bearing query parameters in CLI/CI logs. Log a sanitized URL instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@client/packages/cli/src/commands/info.ts` around lines 36 - 39, Sanitize the
baseUrl value before interpolating it into the error created in the
user-information request handler. Reuse the project’s existing URL-redaction
utility if available, ensuring embedded credentials and token-bearing query
parameters are removed while retaining useful URL context; keep the original URL
for the request itself.

),
);

Expand Down
2 changes: 1 addition & 1 deletion client/packages/version/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// Update the version here and merge your code to main to
// publish a new version of all of the packages to npm.

const version = 'v1.0.54';
const version = 'v1.0.55';

export { version };
Loading