Skip to content

Define validation for the GitHub Node URL input form #489

Description

@shige

Task description

Define validation for the GitHub Node URL input form.

Image

Background

Currently, the application throws an "Invalid GitHub URL" error when an invalid URL is entered in the GitHub Node's URL input form. This indicates a lack of proper input validation. We need to implement client-side validation to prevent these errors and provide a better user experience.

TODO (Optional)

  • Research and determine the valid format(s) for GitHub URLs that our application supports (e.g., repository URLs, specific file URLs, etc.).
  • Implement client-side validation (e.g., using regular expressions or a dedicated library) within the input form. This should provide immediate feedback to the user.
  • Implement (or ensure existing) server-side validation to handle cases where client-side validation is bypassed. This should likely leverage or extend the existing urlToObjectID function in giselle-engine/src/core/github/url-to-object-id.ts.
  • Display user-friendly error messages when an invalid URL is entered. The error message should guide the user on how to correct the input.
  • Write unit and/or integration tests to verify the validation logic.
  • Consider adding visual cues (e.g., input field border color change) to indicate valid/invalid input.

Additional notes (Optional)

  • The relevant file for the core logic seems to be: studio.giselles.ai/../../packages/giselle-engine/src/core/github/url-to-object-id.ts.
  • The error propagates through multiple layers of the application, highlighting the need for robust validation at both the input and processing stages.
  • Consider using a library like validator.js or zod for more complex validation scenarios, if necessary. A simple regular expression may be sufficient, however.
  • Ensure the server-side error handling provides the user a clear, useful error response that helps them correct their input.

Sentry Error Messages:

Error: Invalid GitHub URL
  File "studio.giselles.ai/../../packages/giselle-engine/src/core/github/url-to-object-id.ts", line 16, in urlToObjectID
    throw new Error("Invalid GitHub URL");
  File "studio.giselles.ai/../../packages/giselle-engine/src/core/index.ts", line 97, in <object>.githubUrlToObjectId
    return await urlToObjectID({
  File "studio.giselles.ai/../../packages/giselle-engine/src/http/router.ts", line 143, in <object>.handler
    const objectId = await giselleEngine.githubUrlToObjectId(input.url);
  File "studio.giselles.ai/../../packages/giselle-engine/src/http/create-handler.ts", line 52, in Object.githubUrlToObjectId
    return await handler({
  File "studio.giselles.ai/../../packages/giselle-engine/src/next/next-giselle-engine.ts", line 79, in <anonymous>
    return await jsonRouter[routerPath]({
...
(5 additional frame(s) were not displayed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions