Skip to content

Align the create envfile script to GeoNode project#14434

Open
giohappy wants to merge 1 commit into
masterfrom
align-create-envfile-to-project
Open

Align the create envfile script to GeoNode project#14434
giohappy wants to merge 1 commit into
masterfrom
align-create-envfile-to-project

Conversation

@giohappy

Copy link
Copy Markdown
Contributor

No description provided.

@giohappy giohappy requested a review from mattiagiupponi July 13, 2026 10:02
@cla-bot cla-bot Bot added the cla-signed CLA Bot: community license agreement signed label Jul 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new --authapikey CLI argument to the environment file generator and updates the .env.sample template accordingly, alongside some code formatting improvements. The review feedback highlights three main areas for improvement: handling None values for the email configuration to prevent writing literal 'None' strings to the .env file, replacing the fragile ast.literal_eval parsing of the https flag with a more robust string-matching approach, and removing an unnecessary f-string prefix from the hostname argument help text.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread create-envfile.py
else True
)
_vals_to_replace["debug"] = False if _jsfile.get("env_type", args.env_type) in ["prod", "test"] else True
_vals_to_replace["email"] = _jsfile.get("email", args.email)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

When --email is not provided (which is the default when running in HTTP mode), args.email defaults to None. This causes _vals_to_replace["email"] to be None.

During the template replacement loop, because "email" is in the list of keys that are converted to strings (line 121), str(None) is called, resulting in ADMIN_EMAIL=None being written to the generated .env file.

Providing a fallback to an empty string "" prevents this and ensures that the email field remains empty in the generated .env file when not specified.

Suggested change
_vals_to_replace["email"] = _jsfile.get("email", args.email)
_vals_to_replace["email"] = _jsfile.get("email", args.email) or ""

Comment thread create-envfile.py
Comment on lines +81 to 85
tcp = (
"https"
if ast.literal_eval(f"{_jsfile.get('https', args.https)}".capitalize())
else "http"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using ast.literal_eval on a capitalized string representation of the https parameter is fragile and can easily raise a ValueError or SyntaxError if the input is a string that is not a valid Python literal (for example, if a user specifies "yes", "y", or a malformed string in their JSON configuration).

A more robust and idiomatic approach is to check if the string representation of the value (lowercased) is in a set of truthy values. This safely handles both boolean values and various string representations without risk of throwing parsing exceptions.

        https_val = _jsfile.get("https", args.https)
        tcp = "https" if str(https_val).lower() in ("true", "1", "t", "y", "yes") else "http"

Comment thread create-envfile.py
"-hn",
"--hostname",
help="Host name, default localhost",
help=f"Host name, default localhost",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The f-string here is unnecessary because there are no placeholders or expressions to evaluate. It is cleaner and more idiomatic to use a regular string literal.

Suggested change
help=f"Host name, default localhost",
help="Host name, default localhost",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed CLA Bot: community license agreement signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant