Skip to content

Conversation

@caterryan
Copy link

@caterryan caterryan commented Nov 13, 2025

PyPluginCallApi exposed internal helper method log_args_to_string to plugin code. It shouldn't have been part of the plugin call api PyPluginCallApi.

This PR removes the helper from the api and adds a test.

@caterryan caterryan self-assigned this Nov 13, 2025
raise RuntimeError(f"unexpected attributes: extras={sorted(extras)}, missing={sorted(missing)}")
"#;

let result = system_py::execute_python_with_batch(
Copy link
Contributor

Choose a reason for hiding this comment

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

if you switch to execute_schedule_trigger, you'll get the same effect but won't need to construct the empty write_batch.

)));
let py_cache = PyCache::new_test_cache(cache_store, "method_visibility".to_string());

let query_executor: Arc<dyn QueryExecutor> = Arc::new(UnimplementedQueryExecutor);
Copy link
Contributor

@philjb philjb Nov 13, 2025

Choose a reason for hiding this comment

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

i'd prolly just inline query_executor and py_cache into the call to execute_python_... a matter of taste perhaps, but in a test we can be more concise, especially with setup that is just needed to call the method under test.

probably do the same for db_name (once write_batch is gone) and schema.

use std::time::Duration;

#[tokio::test]
async fn py_plugin_call_api_exposes_only_allowed_methods() {
Copy link
Contributor

Choose a reason for hiding this comment

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

the test method name should start with test_. We don't always follow this pattern but it makes way easier to recognize when a method is a unit test since in rust tests and prod code are in the same files.

speaking of files. it's unusual to have put this test into lib.rs. It would fit better in system_py.rs. Would you move it there unless there is a reason you can't?

@philjb
Copy link
Contributor

philjb commented Nov 13, 2025

The test failure in ci is real:

────────────
     Summary [  39.412s] 789 tests run: 788 passed, 1 failed, 10 skipped
        FAIL [   0.025s] (436/789) influxdb3_py_api tests::py_plugin_call_api_exposes_only_allowed_methods
  stdout ───

    running 1 test
  stderr ───
    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Fatal Python error: Failed to import encodings module
    Python runtime state: core initialized
    ModuleNotFoundError: No module named 'encodings'

    Current thread 0x00007f9874fff6c0 (most recent call first):
      <no Python frame>

    (test failed with exit code 1)

error: test run failed

Copy link
Contributor

@philjb philjb left a comment

Choose a reason for hiding this comment

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

nice find about the exposed helper method; pr needs some changes

  • see if you can move the test to system_py.rs
  • need to fix the test failure ci found
  • switch to execute_schedule_trigger
  • prefix the test name with test_

@philjb
Copy link
Contributor

philjb commented Nov 13, 2025

Your PR description needs to be more accurate too. The only exposed helper is log_args_to_string but the description mentions two methods.

The added test is not an end to end regression test; imo. Again a matter of taste, but i view the pr description as overly verbose (touch grandiose too) as AI generated text often is. At least for the next few months (🤣 😭 ), humans are reading the text still. It pays to be concise (or at least reduce AI verbosity) to save the human time. AI is actually good at reducing its own text, but you have to ask it. "Write my pr description in a concise and technical prose".

How I would edit this: I'm being extra pedantic in your first pr.

PyPluginCallApi exposed internal helper method `log_args_to_string` to plugin code. It shouldn't have been part of the plugin call api `PyPluginCallApi`. 

This PR removes the helper from the api and adds a test.

@philjb
Copy link
Contributor

philjb commented Nov 13, 2025

The commit messages should get the same treatment as the pr description. Again, a matter of taste, but I've found commit messages generated and committed by AI to be too verbose and to me doesn't wrap at 80 (or 100) chars so calling git log is poorly formatted and hard to read.

git commit --amend will let you rewrite the last commit but to write several commits i usually do git rebase -i d9e44a234a9c8fdaa1d3ddecc64c13d5111ea402 and choose the "reword" option.

Screenshot 2025-11-13 at 9 59 05 AM

@caterryan caterryan force-pushed the rcater/26972/PyPluginCallApi_api_leak branch from 2951459 to 890be88 Compare November 13, 2025 20:53
@caterryan caterryan force-pushed the rcater/26972/PyPluginCallApi_api_leak branch from 890be88 to ebc2767 Compare November 13, 2025 23:37
@caterryan caterryan force-pushed the rcater/26972/PyPluginCallApi_api_leak branch from ebc2767 to ba13e6f Compare November 13, 2025 23:44
@caterryan caterryan requested a review from philjb November 14, 2025 12:49
@caterryan
Copy link
Author

Requested changes are complete.

To fix the CI failure, the test was moved to processing_engine because of a dependency on its virtualenv mod.

@philjb philjb added the v3 label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PyPluginCallApi exposes internal helper methods to Python

3 participants