Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Internal Server Error" when creating a table if fields only contain link field. #546

Open
y-t99 opened this issue Apr 8, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@y-t99
Copy link
Collaborator

y-t99 commented Apr 8, 2024

Describe the bug

"Internal Server Error" when creating a table if fields only contain link field.

To Reproduce
Steps to reproduce the behavior:

  1. Create a table id: tblXxx.
  2. Use creating table api:
curl -X 'POST' \
  'https://app.teable.io/api/base/bseXxx/table/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Primary Link Field",
  "fields": [
      {
        "type": "link",
        "name": "Link Field",
        "options": {
          "relationship": "manyMany",
          "foreignTableId": "tblXxx"
        }
      }
  ],
  "fieldKeyType": "name"
}'

Additional context

The source code position where error happend and console output:

@Injectable()
export class FieldSupplementService {
  async generateSymmetricField(tableId: string, field: LinkFieldDto) {
    // ...
    // lookup field id is the primary field of the table to which it is linked
    const { id: lookupFieldId } = await prisma.field.findFirstOrThrow({
      where: { tableId, isPrimary: true },
      select: { id: true },
    });
    // ...
  }
}
prisma:error 
Invalid `prisma.field.findFirstOrThrow()` invocation:

An operation failed because it depends on one or more records that were required but not found. Expected a record, found none.
ERROR (teable/1197): NotFoundError: No Field found
... ...
@y-t99 y-t99 changed the title "Internal Server Error" when creating a table if the primary field is link field. "Internal Server Error" when creating a table if fields contain link field. Apr 9, 2024
@y-t99 y-t99 changed the title "Internal Server Error" when creating a table if fields contain link field. "Internal Server Error" when creating a table if fields only contain link field. Apr 9, 2024
@y-t99
Copy link
Collaborator Author

y-t99 commented Apr 9, 2024

There is another "Internal Server Error":

curl -X 'POST' \
  'https://app.teable.io/api/base/bseXxx/table/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Primary Link Field",
  "fields": [
    {
      "type": "singleLineText",
      "name": "Name",
      "options": {}
    },
    {
      "type": "singleLineText",
      "name": "Name #",
      "options": {}
    }
  ],
  "fieldKeyType": "name"
}'

The source code position where error happend and console output:

@Injectable()
export class FieldService implements IReadonlyAdapterService {
  private async alterTableAddField(
    dbTableName: string,
    fieldInstances: { dbFieldType: DbFieldType; dbFieldName: string }[]
  ) {
      // fieldInstances =[{"name":"Name", "dbFieldName":"Name"}, {"name":"Name #","dbFieldName":"Name"]
      // ...
      await this.prismaService.txClient().$executeRawUnsafe(alterTableQuery);
  }
}
Invalid `prisma.$executeRawUnsafe()` invocation:
Raw query failed. Code: `1`. Message: `duplicate column name: Name`
... ...

@tea-artist tea-artist added the bug Something isn't working label Apr 10, 2024
@tea-artist tea-artist self-assigned this Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants