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

Fix - app deployment issue #154

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

LalitDeore
Copy link
Collaborator

@LalitDeore LalitDeore commented Feb 28, 2025

@frikky Please review once before merging

  1. Fix specical character in issue in function name
  2. Fix same parameter pass two time in same function issue.

codegen.go Outdated
// Create a map to track used parameters
usedParams := make(map[string]bool)

addParameter := func(param string) string {
Copy link
Member

Choose a reason for hiding this comment

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

make this an independent function for cleanliness?

codegen.go Outdated
@@ -2167,6 +2208,10 @@ func FixFunctionName(functionName, actualPath string, lowercase bool) string {
functionName = strings.Replace(functionName, " ", "_", -1)
functionName = strings.Replace(functionName, "-", "_", -1)

functionName = strings.Replace(functionName, "%", "", -1)
Copy link
Member

Choose a reason for hiding this comment

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

can you try handling this by whitelisting characters instead of blacklisting them? notice how:

  • " " -> "" and "-" -> ""
  • but, the rest are just stripped. we can't keep dealing with bullshit characters. might as well strip them away and start from a predictable charset (a-z, A-Z, 1-9)

@frikky any other reviews?

codegen.go Outdated
// Create a map to track used parameters
usedParams := make(map[string]bool)

addParameter := func(param string) string {
Copy link
Member

Choose a reason for hiding this comment

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

Why use an inline function? That is very hard to track compared to just jumping to the right function itself.

Also makes it not reusable.

codegen.go Outdated
@@ -747,14 +747,55 @@ func MakePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
// Extra param for url if it's changeable
// Extra param for authentication scheme(s)
// The last weird one is the body.. Tabs & spaces sucks.

// Create a map to track used parameters
usedParams := make(map[string]bool)
Copy link
Member

Choose a reason for hiding this comment

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

I got a feeling this would crash somewhere due to how maps work.

codegen.go Outdated
paramName = strings.TrimSpace(paramName)

// If parameter hasn't been used before, add it
if !usedParams[paramName] {
Copy link
Member

Choose a reason for hiding this comment

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

Won't this ALWAYS crash the first time?

Don't you gotta do the if value, ok := usedParams[paramName]; ok {} ?

codegen.go Outdated
queryString,
bodyParameter,
verifyParam,
addParameter(strings.TrimPrefix(authenticationParameter, ",")),
Copy link
Member

Choose a reason for hiding this comment

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

I'm scared of this. Sounds like it would break literally everything.

@frikky
Copy link
Member

frikky commented Feb 28, 2025

In short: Your code is not at all trustworthy for our problem, unless it's tested across 1000+ apps and doesn't break a single one. I'm scared of deploying it due to it being VERY big changes to the actual function definitions.

This does not feel like a good solution, as it's a solution on the code generation side (python) and not a solution on the control-mechanism of the incoming OpenAPI

@LalitDeore
Copy link
Collaborator Author

LalitDeore commented Mar 3, 2025

In these two commit ( commit 1, commit 2 ) made the following changes:

  1. Created a new function to check if the same parameter is passed multiple times to the same function without using a map basically with new approach.
  2. Added a function to validate the URL format, ensuring that incorrect URLs like url}/api/v1/user/{id/new are corrected to {url}/api/v1/user/{id}/new
  3. Implemented a regex validation to check that Python function names can only contain letters (a-z, A-Z) and numbers (0-9), with no special characters and replace special character with "_".

Most app deployments were failing due to these issues. To validate this changes, I deployed 8–10 different apps on Frankfurt, and it worked successfully.

@frikky
Copy link
Member

frikky commented Mar 3, 2025

As this is related to App Health, I'm assigning it to you @yashsinghcodes. You are testing similar stuff already, and I need you to make sure we can push this code without it causing even a single old app to stop functioning.

Changing names of actions in one place (python) but not another (app.yaml) have a tendency to create chaos.

@frikky frikky requested a review from yashsinghcodes March 3, 2025 18:56
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.

3 participants