Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-8946

bin/post script stdin detection is faulty

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0
    • Fix Version/s: 5.5.2, 5.6, 6.0.1, 6.1
    • Component/s: SimplePostTool
    • Labels:
      None
    • Environment:

      Ubuntu

      Description

      Summary: I think the post bash script tries to detect stdin the wrong way.

      If I run "post -h" I see some examples, to include this:

      echo '{commit: {}}' | bin/post -c my_collection -type application/json -out yes -d
      

      However if I try it, Solr returns this error: Cannot parse provided JSON: JSON Parse Error: char=<,position=0 BEFORE='<' AFTER='add/>'

      I see that post is sending an <add /> in certain cases, but it's not supposed to when the mode is stdin. Looking closer, it appears to be because of this line:
      if [[ -s /dev/stdin ]]; then
      If I change it to this (which I figured out after googling around; I'm no bash expert!):
      if [[ ! -t 0 ]]; then
      Apparently '0' represents stdin. It works for me. Timothy Potter might you take a look? I'd be happy to add a formal patch & commit for this trivial change but it really needs other eyes.

      1. SOLR_8946.patch
        1 kB
        David Smiley

        Activity

        Hide
        andyetitmoves Ramkumar Aiyengar added a comment -

        +1

        Show
        andyetitmoves Ramkumar Aiyengar added a comment - +1
        Hide
        dsmiley David Smiley added a comment -

        Here's a patch, and I also moved the automatic <add/> params addition to only occur for the "args" mode. It was being added for stdin mode too which was weird.

        AFAICT the former /dev/stdin check worked on Mac OS X / Darwin, but failed on Ubuntu/Debian. I have no idea how, say, Fedora/CentOS would fair. I would appreciate it if someone give it a shot. I did some playing around with bin/post and I think this works and the correct use of <add/> is an improvement too. It would be nice to get this into Solr 5.5.1.

        Show
        dsmiley David Smiley added a comment - Here's a patch, and I also moved the automatic <add/> params addition to only occur for the "args" mode. It was being added for stdin mode too which was weird. AFAICT the former /dev/stdin check worked on Mac OS X / Darwin, but failed on Ubuntu/Debian. I have no idea how, say, Fedora/CentOS would fair. I would appreciate it if someone give it a shot. I did some playing around with bin/post and I think this works and the correct use of <add/> is an improvement too. It would be nice to get this into Solr 5.5.1.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 7833f7f69af4d143178b53879c53563a4bbc0cee in lucene-solr's branch refs/heads/master from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=7833f7f ]

        SOLR-8946: fix bin/post stdin detection. faulty on Ubuntu; maybe others

        Show
        jira-bot ASF subversion and git services added a comment - Commit 7833f7f69af4d143178b53879c53563a4bbc0cee in lucene-solr's branch refs/heads/master from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=7833f7f ] SOLR-8946 : fix bin/post stdin detection. faulty on Ubuntu; maybe others
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit e1a5665feeafd6cd891edff392e885aef648dbf5 in lucene-solr's branch refs/heads/branch_6x from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=e1a5665 ]

        SOLR-8946: fix bin/post stdin detection. faulty on Ubuntu; maybe others
        (cherry picked from commit 7833f7f)

        Show
        jira-bot ASF subversion and git services added a comment - Commit e1a5665feeafd6cd891edff392e885aef648dbf5 in lucene-solr's branch refs/heads/branch_6x from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=e1a5665 ] SOLR-8946 : fix bin/post stdin detection. faulty on Ubuntu; maybe others (cherry picked from commit 7833f7f)
        Hide
        steve_rowe Steve Rowe added a comment -

        Reopening to backport to 6.0.1.

        Show
        steve_rowe Steve Rowe added a comment - Reopening to backport to 6.0.1.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit b119ad60a1d0a58ae4e7a6be54dc3b119bd484b0 in lucene-solr's branch refs/heads/branch_6_0 from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b119ad6 ]

        SOLR-8946: fix bin/post stdin detection. faulty on Ubuntu; maybe others
        (cherry picked from commit 7833f7f)

        Show
        jira-bot ASF subversion and git services added a comment - Commit b119ad60a1d0a58ae4e7a6be54dc3b119bd484b0 in lucene-solr's branch refs/heads/branch_6_0 from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b119ad6 ] SOLR-8946 : fix bin/post stdin detection. faulty on Ubuntu; maybe others (cherry picked from commit 7833f7f)
        Hide
        steve_rowe Steve Rowe added a comment -

        Bulk close issues included in the 6.0.1 release.

        Show
        steve_rowe Steve Rowe added a comment - Bulk close issues included in the 6.0.1 release.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 060902366027239832f532db4250f0d337c1cb96 in lucene-solr's branch refs/heads/branch_5_5 from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=0609023 ]

        SOLR-8946: fix bin/post stdin detection. faulty on Ubuntu; maybe others
        (cherry picked from commit 7833f7f)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 060902366027239832f532db4250f0d337c1cb96 in lucene-solr's branch refs/heads/branch_5_5 from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=0609023 ] SOLR-8946 : fix bin/post stdin detection. faulty on Ubuntu; maybe others (cherry picked from commit 7833f7f)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 0b4a81eaae07a9e271c74f59f586075d3ee00ca1 in lucene-solr's branch refs/heads/branch_5x from David Smiley
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=0b4a81e ]

        SOLR-8946: fix bin/post stdin detection. faulty on Ubuntu; maybe others
        (cherry picked from commit 7833f7f)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 0b4a81eaae07a9e271c74f59f586075d3ee00ca1 in lucene-solr's branch refs/heads/branch_5x from David Smiley [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=0b4a81e ] SOLR-8946 : fix bin/post stdin detection. faulty on Ubuntu; maybe others (cherry picked from commit 7833f7f)
        Hide
        steve_rowe Steve Rowe added a comment -

        Reopening to backport to 5.6 and 5.5.2.

        Show
        steve_rowe Steve Rowe added a comment - Reopening to backport to 5.6 and 5.5.2.
        Hide
        steve_rowe Steve Rowe added a comment -

        Bulk close issues released with 5.5.2.

        Show
        steve_rowe Steve Rowe added a comment - Bulk close issues released with 5.5.2.

          People

          • Assignee:
            dsmiley David Smiley
            Reporter:
            dsmiley David Smiley
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development