Skip to content

fix(workspace): a blank field in altimate.json reads as signed out, not as an unreadable link - #1911

Open
ralphstodomingo wants to merge 1 commit into
mainfrom
fix/1903-blank-credentials-signed-out
Open

ralphstodomingo wants to merge 1 commit into
mainfrom
fix/1903-blank-credentials-signed-out

Conversation

@ralphstodomingo

@ralphstodomingo ralphstodomingo commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1903

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Since #1835 getCredentials() throws on a blank required field. The strict binding read let that through, so the engine overlay treated it as an unreadable workspace link and printed the raw Zod JSON on every run.

  • AltimateApi.getCredentials() throws a typed IncompleteCredentials ("Altimate sign-in is incomplete (… must not be blank); sign in again") when the only problem is a blank altimateUrl, altimateInstanceName or altimateApiKey (after ${env:…} resolution). Any other fault still throws as before.
  • readLocalBindingScopedStrict() reads IncompleteCredentials as unbound (signed out), so the run behaves as it does with no altimate.json: no warning, no refusal.
  • backendConfig() (integrations CLI) returns null for it too, as it does for a missing file.
  • Bad JSON, an unset ${env:…} variable, a read error, or a blank field next to another schema fault still fail closed. A blank key still never loads the gateway as connected.

How did you verify your code works?

  • engine-overlay.test.ts: 8 new tests (each blank field, blank after env resolution, blanking while attached, and three fail-closed cases); 5 of them fail on main. 86 pass, 0 fail.
  • datamate.test.ts checks the typed error and that no Zod JSON shows (54 pass); integrations.test.ts adds a blank-is-signed-out case for backendConfig that fails on main.
  • Real run with a blank altimateInstanceName in a scratch home: main prints Workspace link could not be read: … ([ { "code": "custom", … before the reply; with this change nothing prints.
  • tsgo --noEmit and the marker guard are clean.

Cost side effects

None.

Screenshots / recordings

CLI text only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

🤖 Generated with Claude Code

https://claude.ai/code/session_01BXxzvpym19ATbtFL8LaB6b


Summary by cubic

Fixes blank fields in altimate.json reading as an unreadable workspace link instead of a signed-out state, which printed raw Zod JSON on every run. Closes #1903.

  • getCredentials() now throws a typed IncompleteCredentials ("sign in again") when only a required field is blank after ${env:…} resolution; the strict binding read and backendConfig() treat it as unbound, so runs behave as if altimate.json is missing.
  • Bad JSON, an unset ${env:…} variable, or a blank field alongside another schema fault still fail closed as before; a blank key still never loads the gateway as connected.

Written for commit 8140be7. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Bug Fixes
    • Blank or whitespace-only login details are now treated as signed out, rather than causing confusing credential errors.
    • When login details are incomplete, workspace connections remain unbound, and existing user-managed connections are preserved.
    • Invalid credential files and other credential errors continue to be reported as errors.

… not as an unreadable link

`getCredentials()` throws a typed `IncompleteCredentials` with a plain message when only required fields are blank; the strict binding read and `backendConfig()` treat it as signed out. Bad JSON, an unset `${env:…}` or other schema faults still fail closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BXxzvpym19ATbtFL8LaB6b
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Blank required Altimate credentials now produce a specific incomplete-credentials error. Backend configuration and workspace binding treat that error as signed out, while other credential validation and read errors remain errors.

Changes: Incomplete Altimate credential handling

Layer / File(s) Summary
Classify incomplete credentials
packages/opencode/src/altimate/api/client.ts, packages/opencode/test/altimate/datamate.test.ts
getCredentials throws IncompleteCredentials when validation issues are limited to blank required fields. Tests check the error details and confirm that other schema errors do not use this error type.
Backend configuration fallback
packages/opencode/src/altimate/integrations/backend.ts, packages/opencode/test/altimate/integrations.test.ts
backendConfig returns null for incomplete credentials. Tests also confirm that malformed credentials JSON remains an error.
Workspace binding fallback
packages/opencode/src/altimate/workspace/state.ts, packages/opencode/test/altimate/workspace/engine-overlay.test.ts
readLocalBindingScopedStrict returns an unbound result for incomplete credentials. Tests cover blank and resolved-empty values, blanking credentials while attached, and malformed or otherwise invalid credentials that remain failed link reads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • AltimateAI/altimate-code issue 1905 describes a gateway-model error for a signed-out user with a blank credential field. This change treats blank required credentials as signed out.

Possibly related PRs

Suggested reviewers: sahrizvi, saravmajestic, mdesmet, hkaltai

Merge Risk: Minimal · up to 8140b

A blank credential field in altimate.json now reads as signed out instead of producing a raw validation warning. Other credential faults still fail closed. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a blank required field in altimate.json is now read as signed out rather than as an unreadable workspace link. This matches the changes to getCredentials, the strict b…
Description check Passed The description follows the template. It links issue #1903, marks the change as a bug fix, and explains the cause, the fix, and the fail-closed cases. It reports test results and a manual run. The cos…
Linked Issues check Passed Directly linked issue [#1903] requires that a blank altimateInstanceName or altimateApiKey in altimate.json behave as signed out, print no Zod JSON warning, and show plain sign-in guidance if any mess…
Out of Scope Changes check Passed All changed areas map to the linked issue's objective: the credential read in client.ts, the strict workspace-binding read in state.ts, the integrations backend fallback in backend.ts, and tests in da…
Full details: Title check

Explanation

The title names the main change: a blank required field in altimate.json is now read as signed out rather than as an unreadable workspace link. This matches the changes to getCredentials, the strict binding read, and backendConfig. The title is specific and accurate, though it is long at 95 characters.

Full details: Description check

Explanation

The description follows the template. It links issue #1903, marks the change as a bug fix, and explains the cause, the fix, and the fail-closed cases. It reports test results and a manual run. The cost side-effects section is filled in ('None'), and the checklist is ticked. The template's own rule against large AI-generated descriptions is a concern, but the content is substantive and specific, so the description passes.

Full details: Linked Issues check

Explanation

Directly linked issue [#1903] requires that a blank altimateInstanceName or altimateApiKey in altimate.json behave as signed out, print no Zod JSON warning, and show plain sign-in guidance if any message appears. The PR covers this through the following changes, based on the whole-PR summary and test descriptions: (1) packages/opencode/src/altimate/api/client.ts: getCredentials() uses safe parsing and throws a new IncompleteCredentials error only when every validation issue is a blank required field. Other validation failures still throw the Zod error. (2) packages/opencode/src/altimate/workspace/state.ts: readLocalBindingScopedStrict() returns an unbound result for IncompleteCredentials and rethrows other errors, so no refusal notice is raised. (3) packages/opencode/src/altimate/integrations/backend.ts: backendConfig() returns null for IncompleteCredentials, matching the missing-file path. Tests cover each blank field, blank after env resolution, blanking while attached, and fail-closed cases (bad JSON, unset env var, blank field plus another schema fault). The PR also reports a real run with no warning. The issue's own requirements are coding requirements, and they are addressed. Limitation: the changed-file diff could not be read directly because the changed blobs are missing from the checkout, so this verdict relies on the supplied summary and test descriptions rather than direct source reading.

Full details: Out of Scope Changes check

Explanation

All changed areas map to the linked issue's objective: the credential read in client.ts, the strict workspace-binding read in state.ts, the integrations backend fallback in backend.ts, and tests in datamate.test.ts, integrations.test.ts, and engine-overlay.test.ts that verify the blank-field behavior. The change adds no unrelated feature. The stack-frame tradeoff for blank-plus-schema-fault cases and the explicit-command message change are consequences of the same error path, not separate scope. Limitation: the direct diff could not be read, so this verdict relies on the supplied file summaries and line counts.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the fields at night
Blank credentials take the signed-out path
No raw Zod text leaps from the screen
The workspace rests unbound and calm
Then hops away beneath the moon

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a02d1fa2-5d75-432b-8c74-c7b171a8a073
Commits

Reviewing files that changed from the base of the PR and between cc7c891 and 8140be7.

Files selected for processing: 6

  • packages/opencode/src/altimate/api/client.ts
  • packages/opencode/src/altimate/integrations/backend.ts
  • packages/opencode/src/altimate/workspace/state.ts
  • packages/opencode/test/altimate/datamate.test.ts
  • packages/opencode/test/altimate/integrations.test.ts
  • packages/opencode/test/altimate/workspace/engine-overlay.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@ralphstodomingo

Copy link
Copy Markdown
Contributor Author

Codex review log (local codex exec, reviewed against the claims below)

Claims: C1 a sign-in file that parses and whose only schema issues are blank altimateUrl/altimateInstanceName/altimateApiKey makes getCredentials() throw AltimateApi.IncompleteCredentials (no Zod JSON in its message); every other failure throws what it threw on main. C2 with such a file the workspace binding reads as unbound: nothing printed, no MCP entry removed, an attached engine released as for an unlinked directory; other errors still fail closed. C3 a blank altimateApiKey never makes the Altimate gateway load as connected, and nothing that stopped on main for a blank field now continues with blank values. C4 backendConfig() returns null for IncompleteCredentials, otherwise as on main. C5 scoped credentials are returned untouched.

Accepted: a required field that is missing (not blank) still gives the Zod text; explicit commands now show "sign-in is incomplete" instead of Zod JSON; the skill mirror treats a blank field as "no answer".

Round 1 (head 8140be7): C2–C5 verified. The first run was cut off by Codex's own content filter before a verdict; a reworded run finished.

  • Declined: with a blank field next to another schema issue, the rethrown ZodError has the same class, message and issues as on main, but its stack frames come from safeParse instead of parse. No user-facing path shows that stack.

@ralphstodomingo
ralphstodomingo marked this pull request as ready for review December 5, 2026 01:56
@kilo-code-bot

kilo-code-bot Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/altimate/api/client.ts 118 REQUIRED_FIELDS duplicates the schema's required keys; a later schema change silently reverts blank fields to the Zod/"unreadable link" path. Derive the blank set from parsed.error.issues instead.
Files Reviewed (6 files)
  • packages/opencode/src/altimate/api/client.ts — 1 suggestion
  • packages/opencode/src/altimate/integrations/backend.ts — no issues
  • packages/opencode/src/altimate/workspace/state.ts — no issues
  • packages/opencode/test/altimate/datamate.test.ts — no issues
  • packages/opencode/test/altimate/integrations.test.ts — no issues
  • packages/opencode/test/altimate/workspace/engine-overlay.test.ts — no issues

Review notes: Verified that IncompleteCredentials is only read as signed-out where intended (readLocalBindingScopedStrict, backendConfig); every other getCredentials() caller already handled a throw (catch-all or surfaced message), and apiRequest/dbt-adapter expectations for a missing field still take the Zod path, so no fail-open behaviour or blank-key gateway load was introduced. Other consumers of the strict read (precedence.ts, rules/service.ts) treat signed-out as unbound, consistent with an absent altimate.json.

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 167.6K · Output: 32.1K · Cached: 3.6M

Review guidance: REVIEW.md from base branch main

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@dev-punia-altimate dev-punia-altimate left a comment

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.

🤖 Code Review — OpenCodeReview (Gemini) — 1 finding(s)

  • 1 anchored to a line (posted inline when the comment stream is on)
  • 0 without a line anchor
All findings (full text)

1. packages/opencode/src/altimate/api/client.ts (L123)

[🟠 MEDIUM] In TypeScript, type narrowing on indexed access with dynamic keys (like record[field]) doesn't always work as expected. Even after checking typeof record[field] === "string", the type of record[field] might still be inferred as unknown in strict mode, which will cause a compilation error when calling .trim().

Extracting the property value to a local variable helps TypeScript correctly narrow the type and is generally cleaner.

Suggested change:

    return REQUIRED_FIELDS.filter((field) => {
      const value = record[field]
      return typeof value === "string" && value.trim() === ""
    })

function blankRequiredFields(raw: unknown): string[] {
if (!raw || typeof raw !== "object") return []
const record = raw as Record<string, unknown>
return REQUIRED_FIELDS.filter((field) => typeof record[field] === "string" && record[field].trim() === "")

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.

[🟠 MEDIUM] In TypeScript, type narrowing on indexed access with dynamic keys (like record[field]) doesn't always work as expected. Even after checking typeof record[field] === "string", the type of record[field] might still be inferred as unknown in strict mode, which will cause a compilation error when calling .trim().

Extracting the property value to a local variable helps TypeScript correctly narrow the type and is generally cleaner.

Suggested change:

Suggested change
return REQUIRED_FIELDS.filter((field) => typeof record[field] === "string" && record[field].trim() === "")
return REQUIRED_FIELDS.filter((field) => {
const value = record[field]
return typeof value === "string" && value.trim() === ""
})

@dev-punia-altimate

Copy link
Copy Markdown
Contributor

🤖 Code Review — OpenCodeReview (Gemini) — No Issues Found

No supported files changed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(provider): a blank field in altimate.json prints a raw validation error on every run

2 participants