Thread

Commits

  1. libpq: Improve error message when parsing URI parameters and keywords

  1. Making error message more user-friendly with spaces in a URI

    Yushi Ogiwara <btogiwarayuushi@oss.nttdata.com> — 2024-10-31T01:22:11Z

    Hi,
    
    I made a patch to make the error message more user-friendly when using a 
    URI to connect a database with psql.
    
    Current Error Message:
    
    $ psql "postgres://localhost:5432/postgres?application_name=a b"
    psql: error: trailing data found: "a b"
    
    Currently, if spaces exist in the URI, psql displays this generic error 
    message.
    
    New Error Message (with patch):
    
    psql: error: found unexpected spaces: “a b“. Did you forget to 
    percent-encode spaces?
    
    This revised message is clearer and more concise, guiding users to check 
    for encoding issues.
    
    Regards,
    Yushi Ogiwara
  2. Re: Making error message more user-friendly with spaces in a URI

    Stepan Neretin <sndcppg@gmail.com> — 2024-10-31T15:35:41Z

    >
    > I made a patch to make the error message more user-friendly when using a
    > URI to connect a database with psql.
    >
    
    
    Hi, Yushi! I could not find this line in the master branch and I couldn't
    apply this patch. I only see this error in the test (I think the test
    should also be changed), but the idea of fixing the error looks good to me.
    Best Regards, Stepan Neretin!
    
  3. Re: Making error message more user-friendly with spaces in a URI

    Michael Paquier <michael@paquier.xyz> — 2024-11-01T00:50:02Z

    On Thu, Oct 31, 2024 at 10:35:41PM +0700, Stepan Neretin wrote:
    > Hi, Yushi! I could not find this line in the master branch and I couldn't
    > apply this patch. I only see this error in the test (I think the test
    > should also be changed), but the idea of fixing the error looks good to me.
    
    This line exists on HEAD and the patch applies cleanly today as of
    2d8bff603c9e.  So perhaps just make sure that you are up to date?
    --
    Michael
    
  4. Re: Making error message more user-friendly with spaces in a URI

    Greg Sabino Mullane <htamfids@gmail.com> — 2024-11-01T13:38:57Z

    >
    > $ psql "postgres://localhost:5432/postgres?application_name=a b"
    > psql: error: trailing data found: "a b"
    >
    
    This works fine for me, and sets a space in the application_name string as
    expected. Do you have a different example?
    
    Cheers,
    Greg
    
  5. Re: Making error message more user-friendly with spaces in a URI

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2024-11-05T16:05:14Z

    
    On 2024/11/01 22:38, Greg Sabino Mullane wrote:
    >     $ psql "postgres://localhost:5432/postgres?application_name=a b"
    >     psql: error: trailing data found: "a b"
    > 
    > 
    > This works fine for me, and sets a space in the application_name string as expected. Do you have a different example?
    
    You'll encounter the error message if you run the example command against HEAD.
    
    Regards,
    
    -- 
    Fujii Masao
    Advanced Computing Technology Center
    Research and Development Headquarters
    NTT DATA CORPORATION
    
    
    
    
    
  6. Re: Making error message more user-friendly with spaces in a URI

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2024-11-05T16:09:12Z

    
    On 2024/10/31 10:22, Yushi Ogiwara wrote:
    > Hi,
    > 
    > I made a patch to make the error message more user-friendly when using a URI to connect a database with psql.
    > 
    > Current Error Message:
    > 
    > $ psql "postgres://localhost:5432/postgres?application_name=a b"
    > psql: error: trailing data found: "a b"
    > 
    > Currently, if spaces exist in the URI, psql displays this generic error message.
    > 
    > New Error Message (with patch):
    > 
    > psql: error: found unexpected spaces: “a b“. Did you forget to percent-encode spaces?
    > 
    > This revised message is clearer and more concise, guiding users to check for encoding issues.
    
    I agree the error message could be improved.
    
    The phrasing "Did you forget" feels a bit indirect to me.
    How about using something clearer and more direct instead?
    
    -----------
    psql: error: unexpected spaces found "a b", use percent-encoded spaces instead
    -----------
    
    Regards,
    
    -- 
    Fujii Masao
    Advanced Computing Technology Center
    Research and Development Headquarters
    NTT DATA CORPORATION
    
    
    
    
    
  7. Re: Making error message more user-friendly with spaces in a URI

    Bruce Momjian <bruce@momjian.us> — 2024-11-18T19:59:18Z

    On Wed, Nov  6, 2024 at 01:09:12AM +0900, Fujii Masao wrote:
    > 
    > 
    > On 2024/10/31 10:22, Yushi Ogiwara wrote:
    > > Hi,
    > > 
    > > I made a patch to make the error message more user-friendly when using a URI to connect a database with psql.
    > > 
    > > Current Error Message:
    > > 
    > > $ psql "postgres://localhost:5432/postgres?application_name=a b"
    > > psql: error: trailing data found: "a b"
    > > 
    > > Currently, if spaces exist in the URI, psql displays this generic error message.
    > > 
    > > New Error Message (with patch):
    > > 
    > > psql: error: found unexpected spaces: “a b“. Did you forget to percent-encode spaces?
    > > 
    > > This revised message is clearer and more concise, guiding users to check for encoding issues.
    > 
    > I agree the error message could be improved.
    > 
    > The phrasing "Did you forget" feels a bit indirect to me.
    > How about using something clearer and more direct instead?
    > 
    > -----------
    > psql: error: unexpected spaces found "a b", use percent-encoded spaces instead
    > -----------
    
    +1
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        https://momjian.us
      EDB                                      https://enterprisedb.com
    
      When a patient asks the doctor, "Am I going to die?", he means 
      "Am I going to die soon?"
    
    
    
    
  8. Re: Making error message more user-friendly with spaces in a URI

    Michael Paquier <michael@paquier.xyz> — 2024-11-19T00:29:27Z

    On Mon, Nov 18, 2024 at 02:59:18PM -0500, Bruce Momjian wrote:
    > On Wed, Nov  6, 2024 at 01:09:12AM +0900, Fujii Masao wrote:
    >> The phrasing "Did you forget" feels a bit indirect to me.
    >> How about using something clearer and more direct instead?
    >> 
    >> -----------
    >> psql: error: unexpected spaces found "a b", use percent-encoded spaces instead
    >> -----------
    > 
    > +1
    
    Could it be better to mention %20 in the error message?  Say an
    addition like:
    "unexpected spaces found \"%s\", use percent-encoded spaces (%%20)
    instead"
    --
    Michael
    
  9. Re: Making error message more user-friendly with spaces in a URI

    Tom Lane <tgl@sss.pgh.pa.us> — 2024-11-19T00:52:08Z

    Michael Paquier <michael@paquier.xyz> writes:
    > Could it be better to mention %20 in the error message?  Say an
    > addition like:
    > "unexpected spaces found \"%s\", use percent-encoded spaces (%%20) instead"
    
    +1.  Also the grammar seems a bit off; how about
    
    "unexpected spaces found in \"%s\", use percent-encoded spaces (%%20) instead"
    
    			regards, tom lane
    
    
    
    
  10. Re: Making error message more user-friendly with spaces in a URI

    Michael Paquier <michael@paquier.xyz> — 2024-11-19T01:15:28Z

    On Mon, Nov 18, 2024 at 07:52:08PM -0500, Tom Lane wrote:
    > +1.  Also the grammar seems a bit off; how about
    > 
    > "unexpected spaces found in \"%s\", use percent-encoded spaces (%%20) instead"
    
    That's better, thanks.  This one's on me, so I think that I'll just go
    fix that today with this wording.  This patch was on my bucket list,
    just lost sight of it.
    --
    Michael