Skip to content

fix(cli): resolve project ID from workspace config - #348

Open
CoderSufiyan wants to merge 1 commit into
Infisical:mainfrom
CoderSufiyan:fix/resolve-machine-identity-project-id
Open

fix(cli): resolve project ID from workspace config#348
CoderSufiyan wants to merge 1 commit into
Infisical:mainfrom
CoderSufiyan:fix/resolve-machine-identity-project-id

Conversation

@CoderSufiyan

Copy link
Copy Markdown

Description 📣

Fixes #284.

When machine-identity authentication is used without --projectId or INFISICAL_PROJECT_ID, resolve the project ID from .infisical.json before rejecting the request. Explicit project IDs retain precedence over the workspace configuration.

No new dependencies.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

go test ./packages/util
go build ./...

The regression tests cover explicit project-ID precedence and fallback to workspaceId from the configured .infisical.json.


@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR allows machine-identity secret retrieval to resolve a missing project ID from .infisical.json while retaining explicit project-ID precedence.

  • Adds a shared workspace-ID resolution helper supporting default and explicitly selected configuration directories.
  • Applies the fallback in the universal-auth secret-fetch path.
  • Adds regression tests for explicit-ID precedence and workspace configuration fallback.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking diagnostic issue when workspace configuration resolution fails.

The successful resolution and precedence paths are sound, but malformed, unreadable, or missing workspace configuration is incorrectly presented as merely a missing project ID.

Files Needing Attention: packages/util/secrets.go

Important Files Changed

Filename Overview
packages/util/secrets.go Adds machine-identity workspace fallback correctly, but suppresses actionable errors from reading or parsing the workspace configuration.
packages/util/secrets_test.go Covers explicit project-ID precedence and successful fallback from a workspace configuration directory.

Reviews (1): Last reviewed commit: "fix(cli): resolve project ID from worksp..." | Re-trigger Greptile

Comment thread packages/util/secrets.go
Comment on lines +391 to +393
if err == nil {
params.WorkspaceId = workspaceID
}

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.

P2 Workspace errors lose diagnostics

When .infisical.json is malformed, unreadable, or absent from the configured directory, this branch discards the configuration error and exits with Project ID is required when using machine identity, concealing the problem the user must correct.

Knowledge Base Used: Secrets Management

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.

Error "Project ID is required when using machine identity" with workspaceId defined in .infiscal.json

1 participant