Skip to content

Align the vendored McritClient with MCRIT 1.15.0's client - #45

Merged
danielplohmann merged 1 commit into
familiary:mainfrom
r0ny123:align-client-1.15
Oct 15, 2026
Merged

danielplohmann merged 1 commit into
familiary:mainfrom
r0ny123:align-client-1.15

Conversation

@r0ny123

@r0ny123 r0ny123 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Closes #43.

The vendored client in mcrit_plugin/core/minimcrit/client/McritClient.py matched MCRIT 1.12.0's since #30. This mirrors git diff v1.12.0 v1.15.0 -- mcrit/client/McritClient.py (v1.15.0 is d4de94a) for every method the plugin keeps.

What changes

Core change In the plugin
mcrit#258 A 200 or 202 whose body is not JSON is a failed answer: None by default, McritServerError under raise_server_errors, with a log warning. A body that is not a dict is failed too.
mcrit#255 awaitResult raises JobFailedError(job_id, last_error) for a job that ends without a result, instead of requesting /results/None. JobTerminatedError still comes first. Job.last_error uses .get(), as in core, so a job that never errored has None.
mcrit#177 modifyFamily(..., actors=None) sends JSON and answers the Response in raw mode.
mcrit#217 The matching requests take shortlist_size, band_df_cutoff and preset. The sample-vs-sample and cross comparisons take no shortlist_size, as in core.
mcrit#236 getJobCount and deleteQueueData pass their criteria as params, so they are encoded. _job_selection_query already was.
mcrit#254 One requests.Session per client was already there since #34. Nothing diverged.

isFunctionId loses a raw-mode branch it could never reach. getFunctionById now returns the raw Response before handling it, as core does, so raw mode with a raising mode no longer raises.

Left out: getSampleBinary (mcrit#95), requestBandDfCutoffCoverage and deleteOrphanedQueueFiles are outside the plugin's trimmed surface, as agreed in #28.

Also fixed: modifyFamily, modifySample, requestMatchesForMappedBinary and requestMatchesForUnmappedBinary raised TypeError on every call. They passed the request body positionally to the client's _put/_post wrappers, which only take keyword arguments. The plugin calls none of them, which is how this went unnoticed. The bodies now go as json= or data=, which is what requests.put/requests.post did with them in core. This has its own ### Fixed entry in the changelog.

I compared the two clients method by method after normalising formatting, annotations, docstrings and the plugin's _get/_post wrappers. The only differences left are equivalent forms: keyword instead of positional arguments, data= where core passes the body positionally, _search_base built inline where core has a _search_request helper, and the unique-block params built inline.

Testing

  • tests/core/test_mcrit_client.py has a test for each mirrored behaviour. The tests use real requests.Response objects and check the prepared URLs for the encoding. 23 of them fail against the previous client; the rest guard behaviour that is unchanged.
  • Against a local MCRIT 1.15.0 server, the vendored client:
    • set and cleared a family's actors;
    • stored a sample version;
    • started getMatchesForSample with all three knobs, which reached the job as getMatchesForSample(0, 50, 10, 1, 50, 1000), and awaitResult returned its result;
    • started a server-side binary query and got its result;
    • counted jobs with an encoded filter;
    • deleted queue data with an encoded method.
  • The Binary Ninja 6 GUI integration test passes all 186 checks against MCRIT 1.15.0.
  • ruff format --check, ruff check, run_quality_checks.py, the sync checks and python -m pytest tests (266 tests) pass.

The vendored client matched MCRIT 1.12.0's. This mirrors what changed in
mcrit/client/McritClient.py between v1.12.0 and v1.15.0 for every method
the plugin keeps:

- A 200 or 202 whose body is not JSON, such as a proxy's login page or
  an empty answer, is a failed answer: None by default, McritServerError
  under raise_server_errors, with a log warning. A body that is not a
  dict is failed too. It used to raise a JSON decoding error in every
  mode (mcrit#258).
- awaitResult raises the new JobFailedError, with the job id and the
  queue's last_error, when a job ends without a result, instead of
  requesting /results/None. JobTerminatedError still comes first.
  Job.last_error tolerates a job that never recorded an error, as in
  core (mcrit#255).
- modifyFamily takes actors and sends the update as JSON, since a list
  does not survive form encoding, and answers the Response in raw mode
  (mcrit#177).
- The matching requests take shortlist_size, band_df_cutoff and preset.
  The sample-vs-sample and cross comparisons take no shortlist_size, as
  a shortlist ranked over the corpus could only drop the samples they
  name (mcrit#217).
- getJobCount and deleteQueueData pass their criteria as params, so
  requests encodes them (mcrit#236).
- isFunctionId loses a raw-mode branch it could never reach, and
  getFunctionById returns the raw Response before handling it, as core
  does.
- addBinarySample documents that its query fields are passed through
  as given.

The one requests.Session per client (mcrit#254) was already in place.
getSampleBinary, requestBandDfCutoffCoverage and deleteOrphanedQueueFiles
are outside the plugin's trimmed surface and stay out.

modifyFamily, modifySample and both binary match requests also raised
TypeError on every call: they passed the request body positionally to
the client's _put and _post wrappers, which take it only by keyword. The
bodies now go as json= or data=, matching what requests.put and
requests.post did with them in core.

Each mirrored behaviour has a test in tests/core/test_mcrit_client.py;
the new ones fail against the previous client.

@danielplohmann danielplohmann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this matches core. I compared the methods it touches against v1.15.0 (d4de94a): handle_response, awaitResult with JobFailedError, modifyFamily with actors as JSON, the three matching knobs (left out of the sample-vs-sample and cross compares, as in core), the encoded getJobCount/deleteQueueData params, and the raw-mode order in isFunctionId/getFunctionById. The data= in modifySample and the binary queries is what core's positional body means to requests, so the ### Fixed entry is right.

On the plugin side: nothing calls awaitResult, so JobFailedError cannot reach plugin code. Nothing relied on the old ValueError from a non-JSON 2xx either. The plugin runs in the default mode, so such an answer is now None plus a logged warning.

Merged onto the current main (with #36 and #38), CHANGELOG.md merges cleanly in the order Added / Changed / Fixed. Lint, the sync checks and the suite (288 tests) pass. Against the old client, test_mcrit_client.py does not even import.

@danielplohmann
danielplohmann merged commit ebe3637 into familiary:main Oct 15, 2026
10 checks passed
@r0ny123
r0ny123 deleted the align-client-1.15 branch October 15, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align the vendored McritClient with MCRIT 1.15.0's client

2 participants