p0cli: ls: Troubleshooting
Last updated: May 2, 2025
Troubleshooting Guide: p0 ls
When running p0 ls, you may encounter errors or unexpected output due to authentication issues, network problems, invalid flags, or backend constraints. This guide walks through common scenarios, their causes, and how to resolve them.
1. Authentication & Authorization Failures
Error Message Cause Resolution | ||
Please run 'p0 login <organization>' to use the P0 CLI. | You aren’t logged in or your identity file is missing. | Execute p0 login <your-org-slug> and complete the OIDC flow. |
Could not load credentials for "<name>" | Corrupt or expired credential cache. | Remove the cache directory (rm -rf ~/.p0/identity-cache) and re-run p0 login. |
Silent hang or immediate exit without output | Token auto-refresh failed but no explicit error. | Clear credentials (p0 logout or delete ~/.p0/identity.json) and log in again. |
2. Network & Connectivity Issues
Error Message Cause Resolution | ||
Network error: Unable to reach the server at https://<tenant>/o/<org>/command/. | Cannot connect to the P0 API endpoint (DNS, proxy, firewall). | - Verify your internet connection and DNS lookup.- Check appUrl in ~/.p0/config.json.- Whitelist the endpoint in your proxy/firewall. |
fetch failed | Underlying fetch call timed out or TLS handshake failed. | - Test reachability with curl https://<tenant>/o/<org>/command/.- Ensure your system clock is accurate (TLS requires correct time). |
3. Flag & Usage Errors
Error Message Cause Resolution | ||
Unknown argument: --foo | Typo or unsupported flag. | Check flags with p0 ls --help or p0 ls <provider> --help. |
Invalid number for '--size' | Non-integer or out-of-range value provided. | Use a positive integer: e.g. --size 20. |
No output, even though resources exist | You omitted the provider or subcommand. | Ensure you specify a valid provider and subcommand (e.g., p0 ls aws resource). |
No <arg> | The backend returned zero matches for your query. | Remove or change your search term/filter; try running without arguments. |
4. Subcommand & Provider Validation
Symptom Cause Resolution | ||
Unknown command: ssh | Misspelling or provider not recognized. | Verify provider names with p0 ls --help (must be ssh, not sShh, etc.). |
Empty list from p0 ls ssh session destination | No session destinations match your filter or you lack permissions. | - Try a broader or different search term.- Confirm your account has at least one session destination assigned. |
Backend error JSON (e.g., permission denied) | Your P0 role or tenant configuration does not allow listing. | Ensure your P0 admin has granted your role the “list” permission for that provider integration. |
5. Pagination & Truncation Questions
“Showing the first N…” but you know there are more
CLI fetched 2×size to detect truncation; your --size controls only display.
Resolution: Increase --size to show more items, or add a filter term.
Suggestion “use <like> to narrow results”
This indicates isTruncated=true and no search term was provided.
Resolution: Add a search argument after your subcommand (e.g., p0 ls aws resource logs).
6. JSON Mode Issues
Invalid JSON output or parse errors
Occurs if the backend returns malformed JSON.
Resolution:
Run without --json to see the human output.
Capture raw response with P0_CLI_DEBUG=true p0 ls … and inspect for errors.
Contact P0 support if the payload is not valid JSON.
7. Debugging Tips
Enable debug logs
P0_CLI_DEBUG=true p0 ls …Prints HTTP request/response details to stderr.
Check local config
cat ~/.p0/config.jsonVerify appUrl and any proxy settings.
Test API directly
curl -X POST https://<tenant>/o/<org>/command/ \
-H "Authorization: Bearer $(p0 debug-token)" \
-d '{"argv":["ls","aws","resource",""],"scriptName":"p0"}'Examine raw JSON to ensure the backend is returning items.
Validate provider-side state
If you expect resources to exist, confirm in the native console or CLI (e.g., aws s3 ls, kubectl get pods, etc.).
If you encounter issues not covered here, please collect:
The exact p0 ls command you ran
Full error messages or empty outputs
Debug logs (P0_CLI_DEBUG=true)
Then contact your P0 support team with these details for further assistance.