Skip to content

Conversation

@SujithThirumalaisamy
Copy link

@SujithThirumalaisamy SujithThirumalaisamy commented Jan 25, 2026

Description 📣

When the user is unauthorized and passed a --template flag to the export command. It failed due to no validation of the loggedInUserDetails.LoginExpired value.

Fixes #114

cli/packages/cmd/export.go

Lines 118 to 122 in ba904b4

loggedInUserDetails, err := util.GetCurrentLoggedInUserDetails(true)
if err != nil {
util.HandleError(err)
}
accessToken = loggedInUserDetails.UserCredentials.JTWToken

image

Type ✨

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

Tests 🛠️

  1. Revoke the cli token from Personal Settings
  2. Try to export env with a template
    # This should fail (Old build)
    infisical export --template=/path/to/template
  3. Try to build and export env with the new binary
    # This should invoke login successfully (New fix)
    go build -o infisical . && ./infisical export --template=./template

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 25, 2026

Greptile Overview

Greptile Summary

Fixed missing login expiration check when using the --template flag with the export command. Previously, expired login sessions would cause crashes instead of triggering re-authentication.

  • Added validation for loggedInUserDetails.LoginExpired before extracting JWT token (export.go:123-125)
  • Aligns with the existing pattern used in other commands (secrets.go, ssh.go, etc.)
  • Prevents runtime errors when users have revoked their CLI tokens

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a straightforward bug fix that adds missing validation logic consistent with patterns used throughout the codebase. No breaking changes, security issues, or edge cases identified.
  • No files require special attention

Important Files Changed

Filename Overview
packages/cmd/export.go Added login expiration check before using user credentials for template processing, preventing crashes when tokens are expired

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.

Login flow not triggered while using export command

1 participant