8000 🐛 Bug Report: Incorrect Error Handling When Passing Int as documentId parameter · Issue #7628 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
🐛 Bug Report: Incorrect Error Handling When Passing Int as documentId parameter #7628
Open
@EVDOG4LIFE

Description

@EVDOG4LIFE

👟 Reproduction steps

When attempting to pass an unsupported type property (in this case, an int) when creating a Document, the response erroneously declares:

error: AppwriteException: Invalid documentId param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char

Example code:

import { Client, Databases, ID } from "appwrite";

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');
const databases = new Databases(client);
const id = Date.now(); //this does not work, error recieved is shown after code ends
const promise = databases.createDocument(
    '[DATABASE_ID]',
    '[COLLECTION_ID]',
    id,
    data
);

promise.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});

While the code is incorrect, the error returned does not accurately reflect the actual issue. The value returned is a epoch timestamp as an int. This is fixed by modifying the id generation to a string: const id = Date.now().toString()

👍 Expected behavior

We need to to improve error handling and return the appropriate error when passing an unsupported type and clarify it must be a string.

👎 Actual Behavior

Error returns as Invalid documentId param: Parameter must contain at most 36 chars.

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Linux

🧱 Your Environment

n/a

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcommunityPR or issues handled by the community members who may need guidance from coregood first issueGood for newcomersproduct / databasesFixes and upgrades for the Appwrite Database.

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0