prefect icon indicating copy to clipboard operation
prefect copied to clipboard

Setting empty string for `PREFECT_ORION_API_PORT` does not work

Open liqwid opened this issue 2 years ago • 1 comments

First check

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

Bug summary

PREFECT_ORION_API_PORT should be allowed to be empty to query API at just the host.

Use case is quite common and basic: Our on-prem prefect is deployed at prefect.example.com and we need to be able to access API at http://prefect.example.com/api (ideally option to turn on SSL for API is also required)

Should be a simple fix and will cover one of the most obvious use cases

Reproduction

Set PREFECT_ORION_API_PORT to ''

Error

Traceback (most recent call last):
  File "/usr/local/bin/prefect", line 5, in <module>
    from prefect.cli import app
  File "/usr/local/lib/python3.10/site-packages/prefect/__init__.py", line 26, in <module>
    from prefect.flows import flow, Flow
  File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 36, in <module>
    from prefect.context import PrefectObjectRegistry, registry_from_script
  File "/usr/local/lib/python3.10/site-packages/prefect/context.py", line 522, in <module>
    GLOBAL_SETTINGS_CONTEXT: SettingsContext = root_settings_context()
  File "/usr/local/lib/python3.10/site-packages/prefect/context.py", line 487, in root_settings_context
    profiles = prefect.settings.load_profiles()
  File "/usr/local/lib/python3.10/site-packages/prefect/settings.py", line 1075, in load_profiles
    user_profiles_path = PREFECT_PROFILES_PATH.value()
  File "/usr/local/lib/python3.10/site-packages/prefect/settings.py", line 107, in value
    return self.value_from(get_current_settings())
  File "/usr/local/lib/python3.10/site-packages/prefect/settings.py", line 761, in get_current_settings
    return get_settings_from_env()
  File "/usr/local/lib/python3.10/site-packages/prefect/settings.py", line 777, in get_settings_from_env
    _FROM_ENV_CACHE[cache_key] = Settings()
  File "pydantic/env_settings.py", line 39, in pydantic.env_settings.BaseSettings.__init__
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Settings
PREFECT_ORION_API_PORT
  value is not a valid integer (type=type_error.integer)

Versions


0.5.1

Additional context

No response

liqwid avatar Sep 15 '22 12:09 liqwid

Hi @liqwid! Under the hood Prefect still needs a port to connect, so I don't believe that making it nullable is the right approach. Have you tried setting it to the default http port of 80? I believe that would solve your use case.

bunchesofdonald avatar Sep 15 '22 14:09 bunchesofdonald

This issue was closed because it has been stale for 14 days with no activity. If this issue is important or you have more to add feel free to re-open it.

github-actions[bot] avatar Mar 30 '23 18:03 github-actions[bot]