Skip to content

fix(platform_lifecycle): allow "_global_" special import id for global lifecycle import - #337

Open
kingcrunch wants to merge 1 commit into
jfrog:mainfrom
kingcrunch:fix/GH-331-lifecycle-import-empty-string
Open

fix(platform_lifecycle): allow "_global_" special import id for global lifecycle import#337
kingcrunch wants to merge 1 commit into
jfrog:mainfrom
kingcrunch:fix/GH-331-lifecycle-import-empty-string

Conversation

@kingcrunch

Copy link
Copy Markdown

fix(platform_lifecycle): allow "global" special import id for global lifecycle import

Summary

Terraform CLI rejects empty import IDs in declarative import{} blocks. The platform_lifecycle resource documented importing the global lifecycle with an empty string (terraform import platform_lifecycle.global "" / id = ""), which now fails with:

Error: Invalid import id argument
The import ID value evaluates to an empty string, please provide a non-empty value.

This PR fixes the issue by accepting the non-empty special import id "_global_" for the global lifecycle while continuing to use the actual project_key for project-scoped lifecycles.

We deliberately chose "_global_" over "global" because project keys in the JFrog platform must match ^[a-z][a-z0-9\-]{1,31}$. A plain "global" special import id would therefore shadow a real project named global and make it impossible to import that project's lifecycle. "_global_" is not a valid project key, so it is unambiguous.

Fixes #331

Changes

  • pkg/platform/resource_lifecycle.go
    • Updated ImportState so that "_global_" is treated as the global lifecycle (no project_key set), alongside the existing empty-string handling for backward compatibility with the legacy CLI import.
  • docs/resources/lifecycle.md and examples/resources/platform_lifecycle/import.sh
    • Updated import examples to use "_global_" instead of "".
  • CHANGELOG.md
    • Added bug-fix entry under the unreleased section.

How to verify

  1. Build the provider:
    make build
  2. Run unit/compile tests:
    make test
  3. With a live JFrog instance (>= Access 7.155.0) and JFROG_URL + JFROG_ACCESS_TOKEN set, import the global lifecycle via an import{} block:
    import {
      id = "_global_"
      to = platform_lifecycle.global
    }
    
    resource "platform_lifecycle" "global" {
      promote_stages = [platform_lifecycle_stage.dev.name]
    }

Checklist

  • CHANGELOG.md updated
  • README.md/docs updated if required
  • Code formatted with go fmt
  • Build passes (go build ./...)
  • Unit tests pass (make test)
  • Acceptance tests pass against a live JFrog instance (make acceptance)

I have read the CLA Document and I hereby sign the CLA.

Notes

This merge request was prepared with assistance from AI (opencode:kimi-k2.7-code). I have reviewed and understood the changes and take responsibility for them.

…l lifecycle import

Terraform CLI rejects empty import IDs in declarative import{} blocks.
The global lifecycle was documented to be imported with an empty string,
which fails during Terraform plan/apply.

Use "_global_" instead of "global" as the special import id because
"global" is a syntactically valid project_key (^[a-z][a-z0-9\\-]{1,31}$)
and would shadow a real project named "global". "_global_" is not a valid
project key and is therefore unambiguous.

Fixes jfrog#331

Assisted-by: opencode:kimi-k2.7-code
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@kingcrunch

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@soumyas-dev

Copy link
Copy Markdown
Collaborator

Hi @kingcrunch ,

Thank you for your contribution.

Our CI pipeline issues have been resolved, and we are now accepting contributions again. If you are still interested in submitting this change, please rebase your branch on master and update the CHANGELOG. We look forward to reviewing your pull request.

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 when trying to import lifecycle via import{} block

2 participants