#Tenant Create Error

1 messages ยท Page 1 of 1 (latest)

twilit basalt
#

Hi @patent flame , which version of Permify are you using? And can I find out which version of the Permify node you are using?

patent flame
#

I'm running off docker and it's set to latest

#
services:
  permify:
    image: permify/permify:latest
#

The above is when the port is set to 3476

When I try 3478, I get:

{
    "message": "Failed to create tenant",
    "error": "/base.v1.Tenancy/Create UNAVAILABLE: No connection established. Last error: connect ECONNREFUSED 127.0.0.1:3478 (2024-02-29T15:43:53.589Z)"
}
#

ofc, 3476 is not going to work because it's http ๐Ÿ˜…

twilit basalt
#

latest sometimes get old ones. To be sure, can you switch to v0.7.7?

patent flame
#

Same as before

#

This is my docker yaml file:

version: "3.1"

services:
  permify:
    image: permify/permify:v0.7.7
    container_name: permify
    restart: "on-failure"
    command: "serve"
    volumes:
      - /Users/paul/development/src/github/auth/docker/permify/config:/config
    ports:
      - "3476:3476"
      - "9180:8080"
      - "9090:9090"
      - "50051:50051"
    depends_on:
      - permify-db

  permify-db:
    image:  postgres:latest
    container_name: permify_db
    environment:
      POSTGRES_USER: permify_user 
      POSTGRES_PASSWORD: somePassword 
      POSTGRES_DB: permify
    ports:
      - "5434:5432"
    restart: unless-stopped
#

The config file is the same from the docs.

twilit basalt
#

Could you share the link of the document where you found this?

patent flame
twilit basalt
#

i cannot access the file you sent

twilit basalt
#

Can you add 3478 to the ports section on docker yaml file and try again?

patent flame
#

Sorry about that. Must have gotten blind to that part. ๐Ÿ˜…

Now getting:

{
    "message": "Failed to create tenant",
    "error": "/base.v1.Tenancy/Create UNAVAILABLE: No connection established. Last error: null"
}
twilit basalt
#

where are you sending these requests from?

patent flame
#

From a NextJS API:

// app/createTenant/route.js
import { NextResponse } from "next/server";
const permify = require("@permify/permify-node");

export async function POST() {
 const client = new permify.grpc.newClient({
    endpoint: "localhost:3478",
 });

 try {
    const response = await client.tenancy.create({
      id: "t1",
      name: "tenant 1"
    });

    // Assuming you want to return the response from the Permify API
    return NextResponse.json({ message: 'Tenant created successfully', response });
 } catch (error: any) {
    // Handle any errors that occur during tenant creation
    return NextResponse.json({ message: 'Failed to create tenant', error: error.message }, { status: 500 });
 }
}
twilit basalt
#

Do you see any errors inside the Permify container? Can you send me a screenshot?

patent flame
twilit basalt
#

Thank you for sharing. I am trying to understand the source of the error. Can I ask you to send the same request using Postman or a similar tool?

patent flame
#

For some reason the database was down in the logs, even though it was green in the dashboard. So I have restarted it.

I'm now getting:

{
    "message": "Failed to create tenant",
    "error": "/base.v1.Tenancy/Create UNKNOWN: ERROR_CODE_MISSING_BEARER_TOKEN"
}
patent flame
twilit basalt
#

Yes, this error is normal since authentication (authn) is enabled in your configuration. If you want, you can disable it and test, or you can add '1234567890' as the Bearer token in the request header. The configuration for the authn section is set like this:

#
  enabled: true
  method: preshared
  preshared:
    keys: ["1234567890"]```
patent flame
#

I have disabled that.

Now I get:

{
    "message": "Failed to create tenant",
    "error": "/base.v1.Tenancy/Create INTERNAL: ERROR_CODE_EXECUTION"
}
twilit basalt
#

Can you check the database to see if the tables have been created?

patent flame
#

auto_migrate: false

#

so the tables are not there.

twilit basalt
#

Yes, in the configuration file, the database section is set as follows:

#
  engine: postgres
  uri: postgres://permify_user:somePassword@permify-db:5432/permify
  auto_migrate: false
  max_open_connections: 20
  max_idle_connections: 1
  max_connection_lifetime: 300s
  max_connection_idle_time: 60s
  garbage_collection:
    enabled: true
    interval: 200h
    window: 200h
    timeout: 5m```
#

Can you set auto_migrate to true?

patent flame
#

I've done that. The tables are there now.

#

Now I get:

{
    "message": "Failed to create tenant",
    "error": "/base.v1.Tenancy/Create INVALID_ARGUMENT: ERROR_CODE_UNIQUE_CONSTRAINT"
}
#

because a record already exists

#
{
    "message": "Tenant created successfully",
    "response": {
        "tenant": {
            "id": "t1",
            "name": "tenant 1",
            "createdAt": "2024-02-29T16:21:55.131Z"
        }
    }
}
#

Thanks so much with walking me through this. This is where I wanted to be to start working with permify!

twilit basalt
#

You're welcome. If there is any issue or question, you can write here anytime you want