Skip to content
This repository was archived by the owner on Oct 31, 2021. It is now read-only.
This repository was archived by the owner on Oct 31, 2021. It is now read-only.

Server requests return HTML due to redirect to new codesearch #30

@jessemckenna

Description

@jessemckenna

API requests currently return HTML instead of JSON, resulting in an error. @asankah advised that this is due to requests to cs.chromium.org being redirected to the new codesearch at source.chromium.org, which now requires an API key.

For example, this test script:

g_cs = codesearch.CodeSearch(should_cache=True, source_root='.')
response = g_cs.SendRequestToServer(codesearch.CompoundRequest(
    search_request=[
    codesearch.SearchRequest(query='hello world',
                             return_line_matches=True,
                             lines_context=0,
                             max_num_results=10)
    ]))

Currently hits this error:

Traceback (most recent call last):
  File "C:\Users\jessemckenna\AppData\Roaming\Sublime Text 3\Packages\ChromiumXRefs\third_party\codesearch\messages.py", line 204, in FromJsonString
    d = json.loads(s)
  File "C:\src\depot_tools\bootstrap-3_8_0_chromium_8_bin\python3\bin\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\src\depot_tools\bootstrap-3_8_0_chromium_8_bin\python3\bin\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\src\depot_tools\bootstrap-3_8_0_chromium_8_bin\python3\bin\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Printing the server response, result, from SendRequestToServer before it is passed to FromJSONString shows an HTML response from source.chromium.org.

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