Skip to content

Improve error messages of undefined values #450

Closed

Description

@karlhorky

Hi @porsager ! 👋

I wanted to open an issue to improve the error messages when errors like Error: UNDEFINED_VALUE: Undefined values are not allowed happen.

Currently it's not easy to know what undefined values are being passed, especially if you're passing multiple interpolated values and are not using 100% TypeScript in the project.

If possible, with a code snippet showing the tagged template literal and which parameter is undefined, similar to the experience when you break JSX code in Next.js:

ReferenceError: Badgee is not defined

pages/index.tsx (650:37) @ eval

  648 | <div css={candidateBadgeStyles}>
  649 |   {!isEditing ? (
> 650 |     <Badgee
      |     ^
  651 |       data-cy="candidate-badge"
  652 |       color={
  653 |         (

Screen Shot 2022-08-02 at 18 22 05

Activity

  1. porsager commented on Aug 9, 2022

    @porsager
    Owner

    Agreed, that would be a great improvement, but should at least be done at no cost to performance. Currently the undefined error is thrown before the query string has finished building, but I just did a quick test, and getting an error that includes the part of the string up to the undefined value is pretty easy. Eg.

    sql`
      select
        name, content
      from users
      join posts using(user_id)
      where user_id = ${ undefined }
      limit 1
    `

    would then throw

    Error: UNDEFINED_VALUE: Undefined values are not allowed:
    
        select
          name, content
        from users
        join posts using(user_id)
        where user_id = $1
                         ^ is undefined

    That solves the raw parameter values, but we'd also need to cover the dynamic ones passed using sql(), but I think that should be doable too.

    Would the above be good enough?

  2. porsager commented on Aug 9, 2022

    @porsager
    Owner

    Closing this as we also have #380 :)

  3. changed the title [-]Improve error messages of [/-] [+]Improve error messages of undefined values[/+] on Aug 9, 2022
  4. karlhorky commented on Aug 9, 2022

    @karlhorky
    ContributorAuthor

    Or sorry, didn't see this one, I'll comment over there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions