Skip to content

Conversation

@YewFence
Copy link

Map ID, Comment, and SecretPath when converting raw secrets to models.SingleEnvironmentVariable in the agent secret listing flow.

Description 📣

Problem: Agent template secret/listSecrets drops id, comment, and sometimes secretPath, despite the raw secrets API including them.
Solution: Map ID, Comment, and SecretPath from raw secrets when converting to models.SingleEnvironmentVariable.
Changes: Update GetPlainTextSecretsViaServiceToken, GetPlainTextSecretsV3, and InjectRawImportedSecret to include these fields in the transformed output.

Fixes #103

Type ✨

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

Tests 🛠️

go build -o infisical.exe .

# Write universal auth credentials to local files used by the agent
Set-Content -Path .\client-id -Value <YOUR_CLIENT_ID>
Set-Content -Path .\client-secret -Value <YOUR_CLIENT_SECRET>

# Generate a template that prints metadata (ID/Comment) from listSecrets
@'
{{- with secret "<PROJECT_ID>" "<ENV_SLUG>" "/" }}
{{- range . }}
key={{ .Key }}
id={{ .ID }}
comment={{ .Comment }}
{{- end }}
{{- end }}
'@ | Set-Content -Path .\template-list-secrets.tmpl

# Minimal agent config with a single template render target
@'
infisical:
  address: "https://app.infisical.com/"
  exit-after-auth: true
auth:
  type: "universal-auth"
  config:
    client-id: "./client-id"
    client-secret: "./client-secret"
    remove_client_secret_on_read: false
sinks:
  - type: "file"
    config:
      path: "access-token"
templates:
  - source-path: "./template-list-secrets.tmpl"
    destination-path: "./out.env"
    config:
      polling-interval: 5s
'@ | Set-Content -Path .\agent-config.local.yaml

# Run agent and confirm rendered output includes non-empty id/comment
.\infisical.exe agent --config .\agent-config.local.yaml
# Confirm .\out.env contains non-empty id/comment for a secret with a comment.

Update `GetPlainTextSecretsViaServiceToken`, `GetPlainTextSecretsV3`, and `InjectRawImportedSecret` to explicitly map `ID`, `Comment`, and `SecretPath` fields from raw secrets.

Previously, these metadata fields were omitted during the transformation to `models.SingleEnvironmentVariable`. This commit ensures complete data propagation and improves code readability by formatting struct initializations across multiple lines.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 19, 2026

Greptile Summary

This PR fixes a data loss issue in the agent secret listing flow by mapping missing metadata fields (ID, Comment, SecretPath) when converting raw secrets to models.SingleEnvironmentVariable. The changes ensure complete field propagation across three transformation functions: GetPlainTextSecretsViaServiceToken, GetPlainTextSecretsV3, and InjectRawImportedSecret, enabling templates to access secret metadata for debugging and traceability as documented in the Infisical agent integration guide.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns - it adds missing field mappings that restore documented functionality without behavioral changes.
  • The changes are straightforward data mapping operations that: (1) correctly match API response fields to model struct fields based on verified API models, (2) maintain consistency with existing field mapping patterns in the codebase, (3) restore documented functionality where metadata fields should be available to templates, and (4) have no impact on security, performance, or breaking changes.
  • No files require special attention

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 19, 2026

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

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.

Agent template listSecrets/secret omits id/comment metadata

1 participant