Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

StringHuman causes query to change meaning for some searches #44738

@chwarwick

Description

@chwarwick

The following search string when Parsed then returned to a string with StringHuman and Parsed again is producing different results. This was encountered attempting to make a code insight which parses the original search query to add filters for fork, archive and repo before turning it back into a string to submit the search.

filePath.Clean( AND NOT filepath.Clean(filePath.Join("/",

When parsed this returns:

[
  {
    "and": [
      {
        "value": "filePath.Clean(",
        "negated": false,
        "labels": ["Literal"],
        "range": {
          "start": { "line": 0, "column": 0 },
          "end": { "line": 0, "column": 15 }
        }
      },
      {
        "value": "filepath.Clean(filePath.Join(\"/\",",
        "negated": true,
        "labels": ["Literal"],
        "range": {
          "start": { "line": 0, "column": 20 },
          "end": { "line": 0, "column": 57 }
        }
      }
    ]
  }
]

When this is converted back to a string using StringHuman the following is returned:

(filePath.Clean( AND (NOT filepath.Clean(filePath.Join(\"/\",))

This was not returning any results so to investigate further I parsed this query and saw that the values for each step have changed.

[
  {
    "and": [
      {
        "value": "(filePath.Clean(",
        "negated": false,
        "labels": ["HeuristicDanglingParens", "Literal"],
        "range": {
          "start": { "line": 0, "column": 0 },
          "end": { "line": 0, "column": 16 }
        }
      },
      {
        "value": "(NOT filepath.Clean(filePath.Join(\"/\",))",
        "negated": false,
        "labels": ["HeuristicDanglingParens", "Literal"],
        "range": {
          "start": { "line": 0, "column": 21 },
          "end": { "line": 0, "column": 25 }
        }
      }
    ]
  }
]

/cc @sourcegraph/search-product

Metadata

Metadata

Assignees

Labels

bugAn error, flaw or fault that produces an incorrect or unexpected result, or behavior.team/search-productIssues owned by the search product team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions