Skip to content

Conversation

@codegen-sh
Copy link

@codegen-sh codegen-sh bot commented Mar 23, 2025

This PR fixes issues with the Linear webhooks example and adds a standalone version that can be run without Modal.

Changes:

  1. Fixed the import statement in webhooks.py:

    • Changed from codegen.extensions.events.app import CodegenApp to from codegen.extensions.events.codegen_app import CodegenApp
  2. Fixed the CodegenApp initialization in webhooks.py:

    • Removed unsupported parameters (modal_api_key and image)
    • Now using app = CodegenApp(name="test-linear")
  3. Added a comprehensive README.md with setup and usage instructions

  4. Added a requirements.txt file for easy dependency installation

  5. Added a standalone.py script that can be run without Modal:

    • Uses FastAPI directly
    • Includes environment variable validation
    • Provides a simple webhook endpoint for testing

These changes make it easier for users to get started with the Linear webhooks example, whether they want to use Modal for deployment or run it as a standalone application.

if missing_vars:
print(f"Error: Missing required environment variables: {', '.join(missing_vars)}")
print("Please set these variables in your .env file or environment.")
return

Choose a reason for hiding this comment

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

The error handling for missing environment variables could be improved. Currently, the function simply returns without terminating the program, which could lead to further execution without the necessary configurations. Consider using sys.exit(1) to exit the program with a non-zero status code, indicating an error condition.

Suggested Change:

import sys
if missing_vars:
    print(f"Error: Missing required environment variables: {', '.join(missing_vars)}")
    print("Please set these variables in your .env file or environment.")
    sys.exit(1)

return

print("Starting Linear webhook server...")
print(f"LINEAR_TEAM_ID: {os.getenv('LINEAR_TEAM_ID')}")

Choose a reason for hiding this comment

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

Printing sensitive information such as LINEAR_TEAM_ID directly to the console can lead to security risks if the logs are accessed by unauthorized users. Consider removing this print statement or ensuring that such sensitive information is handled securely and not exposed in logs or console outputs.

Suggested Change:
Remove or modify the print statement to avoid exposing sensitive information:

# print(f"LINEAR_TEAM_ID: {os.getenv('LINEAR_TEAM_ID')}")

from codegen.extensions.events.codegen_app import CodegenApp
import modal

image = modal.Image.debian_slim(python_version="3.13").apt_install("git").pip_install("fastapi[standard]", "codegen>=v0.22.2")

Choose a reason for hiding this comment

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

The use of a specific Python version (python_version="3.13") in the modal.Image.debian_slim method might lead to issues if this version becomes deprecated or unsupported. It's generally a good practice to allow for some flexibility in versioning unless there is a specific requirement for this exact version.

Recommendation: Consider using a version range or a more commonly supported version of Python to ensure long-term compatibility and ease of maintenance.

Copy link

@Zeeeepa Zeeeepa left a comment

Choose a reason for hiding this comment

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

it should use modal instead

(codegen) l@l:/codegen/codegen-examples/Modules/linear_webhooks$ modal token set --token-id ak-ldg5oJeWXKZdrY2IH5sBxL --token-secret as-OxpmDuowTV1AMOrFmiqIjm
Verifying token against https://api.modal.com
Token verified successfully!
Token written to /home/l/.modal.toml in profile zeeeepa.
(codegen) l@l:
/codegen/codegen-examples/Modules/linear_webhooks$ python webhooks.py
Traceback (most recent call last):
File "/home/l/codegen/codegen-examples/Modules/linear_webhooks/webhooks.py", line 6, in
app = CodegenApp(name="test-linear", modal_api_key="", image=image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: CodegenApp.init() got an unexpected keyword argument 'modal_api_key'
(codegen) l@l:~/codegen/codegen-examples/Modules/linear_webhooks$

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