Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a SQLAlchemy Connector block in the UI allows saving an invalid limit that renders the block unable to load #14117

Open
4 tasks done
abrookins opened this issue Jun 18, 2024 · 0 comments
Assignees
Labels
3.x bug Something isn't working

Comments

@abrookins
Copy link
Collaborator

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

If you create a new SQLAlchemy Connector block in the UI, and while doing so, tab into the limit field and delete the default value, saving the form works but you can't load or use the block.

Reproduction

Follow the steps in the UI using the bug summary:
1. Click Blocks -> SQLAlchemy Connector block -> create/add (whatever it is)
2. Tab into the `limit` field and delete the default value
3. Save the form
4. Create a Python file with just the contents of the Block example (loading the block)
5. Run the file

e.g.:
from prefect_sqlalchemy import SqlAlchemyConnector

database_block = SqlAlchemyConnector.load("test")

Error

(env) ~/src/flows mainpython alchemy_problem.py
Traceback (most recent call last):
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/blocks/core.py", line 880, in load
    return cls._from_block_document(block_document)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/blocks/core.py", line 680, in _from_block_document
    block = block_cls.model_validate(block_document.data)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/blocks/core.py", line 1165, in model_validate
    return super().model_validate(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/pydantic/main.py", line 532, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for SqlAlchemyConnector
fetch_size
  Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/int_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/andrew/src/flows/alchemy_problem.py", line 3, in <module>
    database_block = SqlAlchemyConnector.load("dev-orion-connection")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 363, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 240, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/.pyenv/versions/3.12.2/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 223, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 353, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/client/utilities.py", line 103, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrew/src/flows/env/lib/python3.12/site-packages/prefect/blocks/core.py", line 896, in load
    raise RuntimeError(
RuntimeError: Unable to load 'dev-orion-connection' of block type 'sqlalchemy-connector' due to failed validation. To load without validation, try loading again with `validate=False`.

Versions

Version:             3.0.0rc3
API version:         0.8.4
Python version:      3.12.2
Git commit:          8a59fb49
Built:               Mon, Jun 17, 2024 9:13 AM
OS/Arch:             darwin/arm64
Profile:             default
Server type:         server
Pydantic version:    2.7.0

Additional context

No response

@abrookins abrookins added bug Something isn't working needs:triage Needs feedback from the Prefect product team 3.x labels Jun 18, 2024
@desertaxle desertaxle removed the needs:triage Needs feedback from the Prefect product team label Jun 19, 2024
@bunchesofdonald bunchesofdonald self-assigned this Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants