Skip to content

refactor: Verify and improve DatasourceInput value type#4

Draft
google-labs-jules[bot] wants to merge 5 commits into
mainfrom
verify-datasource-input-type-10692253656539910090
Draft

refactor: Verify and improve DatasourceInput value type#4
google-labs-jules[bot] wants to merge 5 commits into
mainfrom
verify-datasource-input-type-10692253656539910090

Conversation

@google-labs-jules

Copy link
Copy Markdown

Updated DatasourceInput.value type hint in api/core/workflow/nodes/datasource/entities.py to Union[str, int, float, bool, list[str], None] to improve type safety and validation.
Added api/tests/unit_tests/core/workflow/nodes/datasource/test_entities.py to test various input types.


PR created automatically by Jules for task 10692253656539910090 started by @asukaminato0721

Updated `DatasourceInput.value` type hint from `Union[Any, list[str]]` to `Union[str, int, float, bool, list[str], None]` to be more specific and strictly validate inputs.
Added unit tests to verify valid and invalid inputs.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@coderabbitai

coderabbitai Bot commented Dec 26, 2025

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@asukaminato0721

Copy link
Copy Markdown
Owner

fix the test

@google-labs-jules

Copy link
Copy Markdown
Author

fix the test

The tests for the datasource input validation (api/tests/unit_tests/core/workflow/nodes/datasource/test_entities.py) are passing. Could you please specify which test you are referring to that needs fixing? Is there another test file or a specific scenario I missed?

@asukaminato0721

Copy link
Copy Markdown
Owner

==================================== ERRORS ====================================
_ ERROR collecting tests/unit_tests/core/workflow/nodes/http_request/test_entities.py _
import file mismatch:
imported module 'test_entities' has this file attribute:
/home/runner/work/dify/dify/api/tests/unit_tests/core/workflow/nodes/datasource/test_entities.py
which is not the same as the test file we want to collect:
/home/runner/work/dify/dify/api/tests/unit_tests/core/workflow/nodes/http_request/test_entities.py
HINT: remove pycache / .pyc files and/or use a unique basename for your test file modules

@google-labs-jules

Copy link
Copy Markdown
Author

==================================== ERRORS ====================================
_ ERROR collecting tests/unit_tests/core/workflow/nodes/http_request/test_entities.py _
import file mismatch:
imported module 'test_entities' has this file attribute:
/home/runner/work/dify/dify/api/tests/unit_tests/core/workflow/nodes/datasource/test_entities.py
which is not the same as the test file we want to collect:
/home/runner/work/dify/dify/api/tests/unit_tests/core/workflow/nodes/http_request/test_entities.py
HINT: remove pycache / .pyc files and/or use a unique basename for your test file modules

Thank you for the detailed error message. I see that the duplicate filename test_entities.py in different directories caused a collection error. I have renamed the new test file to api/tests/unit_tests/core/workflow/nodes/datasource/test_datasource_entities.py to resolve this conflict.

Updated `DatasourceInput.value` type hint from `Union[Any, list[str]]` to `Union[str, int, float, bool, list[str], None]` to be more specific and strictly validate inputs.
Added unit tests to verify valid and invalid inputs.
Renamed test file to avoid conflict.
@asukaminato0721

Copy link
Copy Markdown
Owner
/home/runner/work/dify/dify/api/core/workflow/nodes/datasource/datasource_node.py:233:50 - error: Argument of type "str | int | float | bool | list[str] | None" cannot be assigned to parameter "selector" of type "Sequence[str]" in function "get"
  Type "str | int | float | bool | list[str] | None" is not assignable to type "Sequence[str]"
    "float" is not assignable to "Sequence[str]" (reportArgumentType)
Error: Argument of type "str | int | float | bool | list[str] | None" cannot be assigned to parameter "selector" of type "Sequence[str]" in function "get"
  Type "str | int | float | bool | list[str] | None" is not assignable to type "Sequence[str]"
    "float" is not assignable to "Sequence[str]" (reportArgumentType)

@google-labs-jules

Copy link
Copy Markdown
Author
/home/runner/work/dify/dify/api/core/workflow/nodes/datasource/datasource_node.py:233:50 - error: Argument of type "str | int | float | bool | list[str] | None" cannot be assigned to parameter "selector" of type "Sequence[str]" in function "get"
  Type "str | int | float | bool | list[str] | None" is not assignable to type "Sequence[str]"
    "float" is not assignable to "Sequence[str]" (reportArgumentType)
Error: Argument of type "str | int | float | bool | list[str] | None" cannot be assigned to parameter "selector" of type "Sequence[str]" in function "get"
  Type "str | int | float | bool | list[str] | None" is not assignable to type "Sequence[str]"
    "float" is not assignable to "Sequence[str]" (reportArgumentType)

I have added assert isinstance(datasource_input.value, list) in _generate_parameters to ensure type safety before calling variable_pool.get, which satisfies the type checker.

Updated `DatasourceInput.value` type hint from `Union[Any, list[str]]` to `Union[str, int, float, bool, list[str], None]` to be more specific and strictly validate inputs.
Added unit tests to verify valid and invalid inputs.
Renamed test file to avoid conflict.
Added type assertion in `DatasourceNode._generate_parameters` to resolve static type check errors.
@asukaminato0721

Copy link
Copy Markdown
Owner
 uv --directory api run mypy --exclude-gitignore --exclude 'tests/' --exclude 'migrations/' --check-untyped-defs --disable-error-code=import-untyped .
  shell: /usr/bin/bash -e {0}
  env:
    UV_PYTHON: 3.12
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
core/workflow/nodes/datasource/datasource_node.py:278: error: Incompatible types in assignment (expression has type "str | int | float | list[str] | None", target has type "Sequence[str]")  [assignment]
Found 1 error in 1 file (checked 1452 source files)

@google-labs-jules

Copy link
Copy Markdown
Author
 uv --directory api run mypy --exclude-gitignore --exclude 'tests/' --exclude 'migrations/' --check-untyped-defs --disable-error-code=import-untyped .
  shell: /usr/bin/bash -e {0}
  env:
    UV_PYTHON: 3.12
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
core/workflow/nodes/datasource/datasource_node.py:278: error: Incompatible types in assignment (expression has type "str | int | float | list[str] | None", target has type "Sequence[str]")  [assignment]
Found 1 error in 1 file (checked 1452 source files)

I have added another type assertion assert isinstance(input.value, list) in _extract_variable_selector_to_variable_mapping to satisfy the static type checker there as well.

Updated `DatasourceInput.value` type hint from `Union[Any, list[str]]` to `Union[str, int, float, bool, list[str], None]` to be more specific and strictly validate inputs.
Added unit tests to verify valid and invalid inputs.
Renamed test file to avoid conflict.
Added type assertions in `DatasourceNode` methods to resolve static type check errors.
@asukaminato0721

Copy link
Copy Markdown
Owner

Error: No release type found in pull request title "Verify and improve DatasourceInput value type". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

@google-labs-jules

Copy link
Copy Markdown
Author

Error: No release type found in pull request title "Verify and improve DatasourceInput value type". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

Acknowledged. I will update the PR title to follow the Conventional Commits specification.

Updated `DatasourceInput.value` type hint from `Union[Any, list[str]]` to `Union[str, int, float, bool, list[str], None]` to be more specific and strictly validate inputs.
Added unit tests to verify valid and invalid inputs.
Renamed test file to avoid conflict.
Added type assertions in `DatasourceNode` methods to resolve static type check errors.
@asukaminato0721 asukaminato0721 changed the title Verify and improve DatasourceInput value type refactor: Verify and improve DatasourceInput value type Dec 26, 2025
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.

1 participant