Skip to content

fix(adapters): store omitted optional env vars on import (#1774) - #1804

Merged
helpcodeai merged 2 commits into
HelpCode-ai:mainfrom
GallaGit:fix/import-optional-env-vars
Nov 20, 2026
Merged

helpcodeai merged 2 commits into
HelpCode-ai:mainfrom
GallaGit:fix/import-optional-env-vars

Conversation

@GallaGit

Copy link
Copy Markdown
Contributor

Closes #1774

What was wrong

When an adapter is imported through the API (or from a chat) with credentials but without one of its optional variables, the import only stored the variables that were sent. The setup form stores an optional field left blank as '', and resolvableEnvVars only treats an optional variable as resolved when it is stored like that. So, for example, an MSSQL import without MSSQL_DOMAIN kept {{MSSQL_DOMAIN}} in its auth config, the connector stayed at needs_input ("Still empty: MSSQL_DOMAIN") and its tools did not show up in tools/list.

What this changes

In prepareConnector (packages/backend/src/adapters/adapters.service.ts), when the caller sends at least one credential, every optional variable of the adapter (and of its catalog entry) that was not sent is added as '', the same as the form does.

  • A value the caller sends for an optional variable is kept as it is.
  • A value the operator provides (withOperatorProvided) is applied before this step, so it is not replaced with ''.
  • An import with no credentials (undefined or {}) stores nothing new, like before.

Because prepareConnector is shared, the pre-save check and exerciseReadTools now see the same values as the import.

Tests

  • New tests in adapters.service.spec.ts:
    • an MSSQL import without MSSQL_DOMAIN stores it as '', and the real computeSetupState reports ready;
    • a MSSQL_DOMAIN that is sent is kept;
    • an import without credentials still stores envVars: null.
  • Updated one expectation in secret-guard.flows.spec.ts: a Telegram import without the optional TELEGRAM_DEFAULT_CHAT_ID now stores it as ''. That is what the form already stored, and applyEnvDefaults and the managed-bot code treat '' as "not set".
  • npx tsc --noEmit -p tsconfig.json passes, and eslint reports nothing on the changed files.
  • In the full backend run on my machine, the only failures were in 4 suites that also fail on main without this change (cloudflare.live, jwt-or-management-key.guard, ssrf.util, ee/learning/learning.database). They look environment-related to me (live API token, DNS, real database), but I have not looked into them further.

Open question

About 170 catalog adapters declare optionalEnvVars, and 36 of them use one in authConfig (mostly OAuth refresh tokens). After this change they get '' on an API import, which is what the dashboard form already sends. If you would rather limit this to variables that appear in a placeholder, I'm happy to change it.

@helpcodeai helpcodeai 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.

Thank you, this looks good. Keep it for all optional variables, as you did: it is what the setup form stores, so an import by API and a form install now end up the same. I checked the change for auth, workspace scoping and outbound URLs and found nothing to change. I'll update the branch and merge it.

@helpcodeai
helpcodeai enabled auto-merge (squash) November 20, 2026 08:11
@helpcodeai
helpcodeai merged commit d7cc123 into HelpCode-ai:main Nov 20, 2026
16 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2026
@helpcodeai

Copy link
Copy Markdown
Contributor

Merged, thank you @GallaGit. It ships with v0.55.7 today.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Catalog import via API leaves optional variables unset and hides the connector from MCP

2 participants