# p0 ls

#### **1. Authentication & Authorization Failures** <a href="#id-1-authentication-and-authorization-failures" id="id-1-authentication-and-authorization-failures"></a>

| **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 <ORG ID>` and complete the OIDC flow.                   |
| Could not load credentials for "\<name>"                 | Corrupt or expired credential cache.                   | Remove the cache directory (`rm -rf ~/.p0/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 `identity.json`) and log in again. |

***

#### **2. Network & Connectivity Issues** <a href="#id-2-network-and-connectivity-issues" id="id-2-network-and-connectivity-issues"></a>

| **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). | <p>Verify your internet connection and DNS lookup.<br><br>Check appUrl in <code>\~/.p0/config.json</code><br><br>Whitelist the endpoint in your proxy/firewall.</p> |
| fetch failed                                                                       | Underlying fetch call timed out or TLS handshake failed.      | <p>Test reachability with curl <code>https\://\<tenant>/o/\<org>/command/</code><br><br>Ensure your system clock is accurate (TLS requires correct time).</p>       |

***

#### **3. Flag & Usage Errors** <a href="#id-3-flag-and-usage-errors" id="id-3-flag-and-usage-errors"></a>

| **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** <a href="#id-4-subcommand-and-provider-validation" id="id-4-subcommand-and-provider-validation"></a>

| **Symptom**                                         | **Cause**                                                          | **Resolution**                                                                                                           |
| --------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| Unknown command: ssh                                | Misspelling or integration not recognized.                         | Verify integration 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. | <p>Try a broader or different search term.</p><p>Confirm your account has at least one session destination assigned.</p> |
| Backend error JSON (for example, 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** <a href="#id-5-pagination-and-truncation-questions" id="id-5-pagination-and-truncation-questions"></a>

* **"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** <a href="#id-6-json-mode-issues" id="id-6-json-mode-issues"></a>

* **Invalid JSON output or parse errors**
  * Occurs if the backend returns malformed JSON.
  * **Resolution**:
    1. Run without --json to see the human output.
    2. Contact P0 support if the payload is not valid JSON.

***

1. **Enable debug `--debug`**
2. Prints HTTP request/response details to stderr.
3. **Check local config**

```plaintext
cat ~/.p0/config.json
```

2. Verify appUrl and any proxy settings.
3. **Test API directly**

```plaintext
curl -X POST https://<host>/o/<org>/command/ \
  -H "Authorization: Bearer $(token)" \
  -d '{"argv":["ls","aws","resource",""],"scriptName":"p0"}'
```

4. Examine raw JSON to ensure the backend is returning items.
5. **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.).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.p0.dev/p0-cli/troubleshooting/p0-ls.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
