This reference covers common issues and their solutions when using kongctl.
Troubleshooting kongctl
Common issues
“No changes detected” when changes exist
Symptom: Modified configuration but plan shows no changes, or resources appear unchanged after apply.
Causes:
- Resource already matches desired state
- Invalid resource references
- Namespace mismatch
Solutions:
Dump current state and compare with your configuration:
kongctl dump declarative --resources <your-resource-type> --output-file current-state.yaml
# or
kongctl dump tf-import --resources <your-resource-type>
diff current-state.yaml your-config.yamlCheck resource references are spelled correctly and match a declared ref:
grep "ref:" your-config.yamlVerify the resource has the expected namespace label in Konnect:
kongctl get apis -o json“Resource not found” errors
Symptom: Error during plan or apply referencing a non-existent resource.
Example:
Error: resource "my-portal" not foundSolutions:
Check whether the resource exists:
kongctl get portals | grep my-portalVerify the ref spelling in your configuration files:
grep -n "my-portal" *.yamlEnsure dependencies are applied first when resources reference each other:
kongctl apply -f portals.yaml
kongctl apply -f apis.yaml
kongctl apply -f publications.yamlAuthentication issues
“Authentication required” or “unauthorized” errors
Symptom: Commands fail with authentication errors.
Solutions:
-
Verify you’re logged in:
kongctl get meCopied! -
Re-authenticate:
kongctl logout kongctl loginCopied! -
If using a PAT, verify it’s set:
echo $KONGCTL_DEFAULT_KONNECT_PAT | head -c 20Copied! -
Check that the token hasn’t expired in Konnect.
-
Verify that
regionis configured as expected.
Browser login timeout
Symptom: Browser authorization doesn’t complete in time.
Solutions:
-
Complete authorization within the time limit (usually 15 minutes).
-
If timeout occurs, start over:
kongctl loginCopied! -
Verify that your browser isn’t blocking the redirect.
Multiple authentication methods conflict
Symptom: Unexpected authentication behavior or wrong credentials being used.
Solution: Check and clear auth methods, if needed.
kongctl resolves authentication in this priority order (highest to lowest):
-
--patflag -
KONGCTL_<PROFILE>_KONNECT_PATenvironment variable - Stored token from
kongctl login
To start fresh and clear all auth methods:
unset KONGCTL_DEFAULT_KONNECT_PAT
kongctl logout
kongctl loginIf you manage profiles outside the default path, you may also need to remove
~/.config/kongctl/.<profile>-konnect-token.jsonmanually.
Configuration errors
YAML parsing errors
Symptom:
Error: yaml: unmarshal errors:
line 10: cannot unmarshal !!str `true` into boolSolution: Ensure field values use the correct YAML type. For example, for a boolean value:
authentication_enabled: trueDuplicate resource references
Symptom:
Error: duplicate resource ref "my-api" foundSolution: Each ref must be unique across all loaded configuration files. Find duplicates and rename them:
grep -n "ref: my-api" *.yamlInvalid field values
Symptom:
Error: invalid value for field "visibility": "internal"Solution: Check the allowed values in the supported resources reference:
api_publications:
- ref: my-pub
visibility: private # Allowed values: public, privateFile loading and YAML tags
File not found errors
Symptom:
Error: failed to process file tag: file not found: ./specs/api.yamlSolutions: Look for the following common errors:
-
Incorrect relative path: paths must be relative to the config file, not the working directory:
spec: !file ./specs/api.yamlCopied! -
Wrong base directory: If your spec file is outside the config file’s directory:
project/ ├── config/ │ └── main.yaml └── specs/ └── api.yamlIn
config/main.yaml, you would access the file like this:spec: !file ../specs/api.yamlCopied!If you see
path resolves outside base dir, use the--base-dirflag or theKONGCTL_DEFAULT_KONNECT_DECLARATIVE_BASE_DIRenvironment variable to set an allowed boundary. -
File permissions: Verify the file is readable:
ls -la ./specs/api.yaml chmod 644 ./specs/api.yamlCopied!
Invalid YAML tag extraction path
Symptom:
Error: path not found: info.nonexistent.fieldSolution:
- Review the YAML path closely, looking for typos or incorrect paths.
-
Use dot notation for arrays instead of bracket array syntax:
server: !file ./spec.yaml#servers.0.urlCopied!
Malformed YAML tag syntax
Symptom:
Error: failed to parse file reference: invalid tag formatSolution: Check the correct map format for !file:
title: !file
path: ./spec.yaml
extract: info.titleLarge file errors
Symptom:
Error: file size exceeds limit: ./large-spec.yaml (12MB > 10MB limit)Solutions:
Split large files, or extract only the values you need rather than loading the entire file.
For example, with a large file named huge-openapi-spec.yaml, access only the data you need:
name: !file ./huge-openapi-spec.yaml#info.title
version: !file ./huge-openapi-spec.yaml#info.versionCross-resource references
Unknown resource references
Symptom:
Error: resource "my-api" references unknown portal: unknown-portalSolutions: Look for the following common errors:
-
Typo in the ref value: The ref must exactly match the
reffield of the target resource:portals: - ref: developer-portal # Exact ref value api_publications: - ref: api-pub portal_id: !ref developer-portal # Matches the portal refCopied! -
Nested vs separate resource conflict: Don’t declare the same ref both nested and at the root:
# Wrong - v1 is declared twice apis: - ref: my-api versions: - ref: v1 # Nested api_versions: - ref: v1 # Conflict api: my-apiCopied!
External ID vs reference confusion
Symptom:
Error: resource references unknown control_plane_id: my-control-planeSolution: Fields like control_plane_id expect a Konnect UUID, not a declarative ref.
Use !ref to resolve a declarative resource’s ID:
api_implementations:
- ref: impl
service:
control_plane_id: !ref my-control-plane#idPlanning issues
Plan generation hangs
Symptom: kongctl plan doesn’t complete.
Solutions:
Enable debug logging to see where it’s stuck:
kongctl plan -f config.yaml --log-level debugTest network connectivity to Konnect:
kongctl get portalsTry planning a smaller configuration to isolate the issue:
kongctl plan -f single-resource.yamlCircular dependencies
Symptom:
Error: circular dependency detected: api1 -> api2 -> api1Solution: Restructure your configuration to break the cycle by introducing a shared base resource or removing the circular reference.
Plan artifact debugging
Invalid plan file
Symptom:
Error: failed to read plan: invalid plan formatSolutions:
Validate the plan file is valid JSON:
cat plan.json | jq . > /dev/nullRegenerate the plan if it’s corrupted:
kongctl plan -f config.yaml --output-file plan.jsonStale plan artifact
Symptom: You see the following error:
Error: plan is out of date - resource already existsSolution: Regenerate the plan to reflect the current live state:
kongctl plan -f config.yaml --output-file new-plan.jsonInspecting plan contents
View the plan summary:
jq '.summary' plan.jsonList all planned operations:
jq '.changes[] | {action: .action, type: .resource_type, ref: .resource_ref}' plan.jsonFilter to specific operations:
# Show only CREATE operations
jq '.changes[] | select(.action == "CREATE")' plan.jsonExecution failures
Partial apply failures
Symptom: Some resources are created successfully, others fail. Apply reports errors for specific resources.
Solution: Fix the failing resource configuration and re-run apply. The apply command is idempotent, so existing resources are skipped:
kongctl apply -f config.yamlProtected resource blocking changes
Symptom: You see the following error:
Error: Cannot modify protected resource "production-api"Solution: Temporarily set protected: false, apply your changes, then re-enable protection:
apis:
- ref: production-api
kongctl:
protected: false # Changed from trueSync deleting unexpected resources
Symptom: Resources are deleted that shouldn’t be.
Prevention: Always dry-run before syncing, especially in production:
kongctl sync -f config.yaml --dry-runUse namespaces to limit sync scope to only your team’s resources. Check which resources are managed by kongctl before syncing:
kongctl get apis -o jsonPerformance issues
Slow plan generation
Symptom: Plans take a long time to generate.
Solution: Check the logs to identify the problem, and split large configurations as needed.
Enable trace logging to identify slow API calls:
kongctl plan -f config.yaml --log-level traceSplit large configurations into smaller files and plan them separately:
kongctl plan -f apis-batch-1.yaml
kongctl plan -f apis-batch-2.yamlCheck for 429 (rate limiting) status codes in trace logs.
High memory usage with file tags
When loading the same large file multiple times, extract only the fields you need. Files are cached within a single execution, so referencing the same file multiple times is efficient:
# Instead of loading the full spec repeatedly
apis:
- ref: api-1
name: !file ./common.yaml#api.name # Loaded and cached
description: !file ./common.yaml#api.desc # Uses cache
- ref: api-2
team: !file ./common.yaml#team.name # Uses cacheDebugging
Enable debug logging
Show detailed operation logs:
kongctl apply -f config.yaml --log-level debugShow API requests and responses:
kongctl apply -f config.yaml --log-level traceYou can also set these via environment variables:
export KONGCTL_LOG_LEVEL=debug
kongctl plan -f config/Trace log analysis
When trace logging is enabled, look for:
-
4xx/5xxHTTP status codes - Slow response times
- Unexpected response bodies
Example trace output:
time=2024-01-15T12:00:00.000Z level=TRACE msg="HTTP request" method=GET url=https://us.api.konghq.com/v2/portals
time=2024-01-15T12:00:01.000Z level=TRACE msg="HTTP response" status=200 duration=1sStep-by-step debugging workflow
Use this sequence to isolate issues:
- Validate YAML syntax:
cat config.yaml | python -m yamlCopied! - Test authentication:
kongctl get portalsCopied! - Generate plan with debug logging:
kongctl plan -f config.yaml --mode apply --log-level debug --output-file plan.jsonCopied! - Review the plan:
cat plan.json | jq '.changes'Copied! - Dry-run the apply:
kongctl apply --plan plan.json --dry-runCopied! - Apply with trace logging:
kongctl apply --plan plan.json --log-level traceCopied!
Verify configuration
Verify that the configuration file is valid:
cat ~/.config/kongctl/config.yamlTest API connectivity
Make a direct API call to test API connectivity:
kongctl api /v3/portalsCheck version
Ensure you’re running the latest version:
kongctl version --fullUpdate kongctl if needed following the install instructions for your platform.
Quick reference
Error patterns
|
Error |
Likely cause |
Quick fix |
|---|---|---|
| unauthorized | Expired token |
kongctl login
|
| not found | Wrong resource reference |
Check spelling of ref values
|
| invalid value | Wrong type or format | Check the supported resources reference |
| file not found | Wrong file path | Use paths relative to the config file |
| protected resource | Protection enabled |
Temporarily set protected: false
|
| circular dependency | Resource reference loop | Restructure to remove the cycle |
| path not found | Invalid extraction path | Check the YAML structure of the source file |
| exceeds limit | File too large | Split the file or extract only needed values |
Useful environment variables
# Set log level globally
export KONGCTL_LOG_LEVEL=debug
# Use a specific profile
export KONGCTL_PROFILE=production
# Set PAT for the default profile
export KONGCTL_DEFAULT_KONNECT_PAT="your-token-here"Prevention tips
- Always dry-run (
--dry-run) before applying in production. - Use version control for all configuration files.
- Test changes in a lower environment before production.
- Use namespaces to isolate changes between teams and environments.
- Enable trace logging when debugging unexpected behavior.
- Review plans before applying by using the two-phase plan and apply workflow.
- Validate YAML syntax before deploying.
- Check file paths are relative to the config file, not the working directory.
- Monitor file sizes to stay under the 10MB limit.
- Use
protected: trueon production resources to prevent accidental deletion.
Getting help
If you’re still experiencing issues, do the following:
-
Check GitHub issues for similar problems.
-
Review GitHub discussions.
- Open a new issue containing the following information:
- kongctl version (
kongctl version --full) - Operating system
- Command that failed
- Full error message
- Debug logs (with sensitive data redacted)
- kongctl version (
- Contact Kong Support if you’re an enterprise customer.