Improve CONTENT environment variable handling
- Update endpoint to check for both None and empty string values - Add more detailed error message for better user experience - Update documentation to reflect the refined behavior
This commit is contained in:
parent
1df01b998d
commit
6a19bf4aa7
@ -10,7 +10,8 @@ router = APIRouter()
|
|||||||
"/env/content",
|
"/env/content",
|
||||||
response_model=Dict[str, str],
|
response_model=Dict[str, str],
|
||||||
summary="Get content from CONTENT environment variable",
|
summary="Get content from CONTENT environment variable",
|
||||||
description="Returns the value of the CONTENT environment variable"
|
description="Returns the value of the CONTENT environment variable "
|
||||||
|
"if set and not empty"
|
||||||
)
|
)
|
||||||
def get_content_env_var():
|
def get_content_env_var():
|
||||||
"""
|
"""
|
||||||
@ -20,14 +21,14 @@ def get_content_env_var():
|
|||||||
dict: A dictionary containing the CONTENT environment variable value
|
dict: A dictionary containing the CONTENT environment variable value
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
HTTPException: If the CONTENT environment variable is not set
|
HTTPException: If the CONTENT environment variable is not set or is empty
|
||||||
"""
|
"""
|
||||||
content_value = os.environ.get("CONTENT")
|
content_value = os.environ.get("CONTENT")
|
||||||
|
|
||||||
if content_value is None:
|
if content_value is None or content_value == "":
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail="CONTENT environment variable is not set"
|
detail="CONTENT environment variable is not set or is empty"
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"content": content_value}
|
return {"content": content_value}
|
Loading…
x
Reference in New Issue
Block a user