corepack pnpm permit:bootstrap -- --env dev > ...
# permit-saas
a
corepack pnpm permit:bootstrap -- --env dev
minduo@0.1.0 permit:bootstrap /Users/alechandal/Repos/minduo
tsx scripts/permit/bootstrap-resources.ts -- --env dev
{"level":50,"time":"2025-11-03T172247.414Z","label":"permit-bootstrap","msg":"Got error status code: 500, err:{\"id\":\"30f50c095157412cb3370c9bb5656428\",\"title\":\"The request could not be completed\",\"error_code\":\"UNEXPECTED_ERROR\",\"message\":\"You did nothing wrong, but we could not finish your request due to a technical issue on our end. Please try again.\\nIf the issue keeps happening, contact our support.\"}"} Failed to bootstrap Permit resources PermitApiError: You did nothing wrong, but we could not finish your request due to a technical issue on our end. Please try again. If the issue keeps happening, contact our support for further guidance. at ResourcesApi2.handleApiError (...) at ResourcesApi2.replace (...) at async main (.../scripts/permit/bootstrap-resources.ts2525) { originalError: AxiosError: Request failed with status code 500 at settle (...) at IncomingMessage.handleStreamEnd (...) at process.processTicksAndRejections (...) at Axios.request (...) at async ResourcesApi2.replace (...) at async main (.../scripts/permit/bootstrap-resources.ts2525) { code: 'ERR_BAD_RESPONSE', config: { baseURL: 'http://localhost:7766/', method: 'put', data: '{"name":"Organization","actions":{"create":{},"invite":{},"deprovision":{}},"attributes":{"orgId":{"type":"string","description":"Primary key from Minduo database"}}}', url: 'https://api.permit.io/v2/schema/<project-id>/<env-id>/resources/organization', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json', 'X-Permit-SDK-Version': 'node:0.1.0', Authorization: 'Bearer <REDACTED>', 'User-Agent': 'axios/1.13.1', 'Content-Length': 166, 'Accept-Encoding': 'gzip, compress, deflate, br', Host: 'api.permit.io', Connection: 'keep-alive' }, // remaining axios metadata omitted for brevity }, response: { status: 500, statusText: 'Internal Server Error', headers: { /* redacted */ }, data: { /* redacted */ } }, status: 500 } }
a
Hi @Alec Handal, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Looking at your error, you're getting a 500 Internal Server Error when trying to replace a resource. The error shows your script is using the Node.js SDK's
replace
method (1) to bootstrap resources. The issue appears to be a configuration mismatch - your axios config shows
baseURL: '<http://localhost:7766/>'
(which would be a local PDP) , but the actual request is going to
'<https://api.permit.io/v2/schema/<project-id>/<env-id>/resources/organization>'
. This suggests there might be a conflict in your configuration. Based on the Node.js SDK implementation , the
replace
method:
Copy code
public async replace(resourceKey: string, resourceData: ResourceReplace) : Promise<ResourceRead> {
    await this.ensureAccessLevel(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY) ;
    await this.ensureContext(ApiContextLevel.ENVIRONMENT) ;
    try {
      return (
        await this.resources.replaceResource({
          ...this.config.apiContext.environmentContext,
          resourceId: resourceKey,
          resourceReplace: resourceData,
        })
      ) .data;
    } catch (err) {
      this.handleApiError(err) ;
    }
  }
To help our engineers investigate this issue further, could you please provide: 1. Which Workspace / Project / Env you are using (looks like you have
<project-id>/<env-id>
in the URL) 2. The exact SDK calls you're performing (your bootstrap script code) 3. Which PDP version you are running (if using a local PDP at localhost:7766) 4. Any relevant logs from your PDP if you're running one locally This will help identify whether it's a configuration issue or a server-side problem.
To learn more, see the sources I considered: [[1] permitio/permit-node/src/api/resources.ts](https://github.com/permitio/permit-node/blob/main/src/api/resources.ts)
a
Here's all the requested info: 1. Workspace / Project / Env • Workspace: Minduo • Project ID: 7f33972704a44527b05ae0fa3d9828c6 • Environment ID: ce26559d1cfa4d00bb4f097a46ea0e85 (dev) 2. Exact SDK calls (bootstrap script)
Copy code
const permit = new Permit({
  token: requireEnv("PERMIT_API_KEY"),
  environment: targetEnv,                 // defaults to dev
  pdp: process.env.PERMIT_PDP_URL,        // <http://localhost:7766> when the PDP is running
  apiUrl: process.env.PERMIT_API_URL,     // unset → defaults to Permit cloud API
  log: {
    level: process.env.NODE_ENV === "production" ? "warn" : "info",
    label: "permit-bootstrap",
    json: false,
  },
});

for (const resource of resources) {
  const payload = {
    name: resource.name,
    description: resource.description,
    actions: toActionMap(resource.actions),        // e.g. { create: {}, invite: {}, ... }
    attributes: toAttributeMap(resource.attributes),
    relations: resource.relations,
  };

  await permit.api.resources.replace(resource.key, payload);
  console.log(`Synced resource schema: ${resource.key}`);
}
The failing call is permit.api.resources.replace("organization", { ... }), which expands to a PUT on https://api.permit.io/v2/schema/<project-id>/<env-id>/resources/organization. The payload for that first call is:
Copy code
{
  "name": "Organization",
  "actions": {
    "create": {},
    "invite": {},
    "deprovision": {}
  },
  "attributes": {
    "orgId": {
      "type": "string",
      "description": "Primary key from Minduo database"
    }
  }
}
3. PDP version • Container image: permitio/pdp-v2:latest • Exposed at http://localhost:7766 4. Recent PDP logs
Copy code
2025-11-03T17:24:42Z | uvicorn.protocols.http.httptools_impl | INFO | 127.0.0.1:37356 - "GET /healthy HTTP/1.1" 200
2025-11-03T17:24:47Z | uvicorn.protocols.http.httptools_impl | INFO | 127.0.0.1:37356 - "GET /healthy HTTP/1.1" 200
… (repeated /healthy probes every ~5s)
2025-11-03T17:29:22Z | uvicorn.protocols.http.httptools_impl | INFO | 127.0.0.1:37082 - "GET /healthy HTTP/1.1" 200
No error output from the PDP; it just responds to the health checks.
a
Hey @Alec Handal, Looping in the team, will circle back to you soon
❤️ 1
t
Still investigating, will have more info in the AM.
👍 1
a
Thanks — appreciate the expediency! Just migrated over from Cerbos
a
Hey @Alec Handal, We found the issue — it happens because the nested action creation isn’t handled correctly. As a workaround, you can add a name field inside each action block. For example, change from:
Copy code
"actions": {
  "create": {},
  "deprovision": {},
  "invite": {}
}
To:
Copy code
"actions": {
  "create": { "name": "create" },
  "deprovision": { "name": "deprovision" },
  "invite": { "name": "invite" }
}
This should resolve the problem. Please let us know if it works on your end.
a
Works now! Thank you
💜 3