Skip to content

Conversation

@misrasaurabh1
Copy link
Contributor

@misrasaurabh1 misrasaurabh1 commented Oct 16, 2025

PR Type

Enhancement


Description

  • Use configurable base URL for staging links

  • Import CFAPI base URL constant


Diagram Walkthrough

flowchart LR
  code["function_optimizer.py"] -- "import CFAPI_BASE_URL" --> importChange["Config-driven URL"]
  importChange -- "build staging URL" --> urlChange["Use CFAPI_BASE_URL in link"]
Loading

File Walkthrough

Relevant files
Enhancement
function_optimizer.py
Replace hardcoded staging domain with configurable base URL

codeflash/optimization/function_optimizer.py

  • Import CFAPI_BASE_URL from codeflash.api.cfapi.
  • Build staging URL using CFAPI_BASE_URL instead of hardcoded domain.
+2/-2     

Signed-off-by: Saurabh Misra <[email protected]>
@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

URL Construction

Ensure CFAPI_BASE_URL does not include a trailing slash to avoid double slashes in the constructed staging URL, and confirm it’s the correct base for user-facing links (app vs API).

staging_url = f"{CFAPI_BASE_URL}/review-optimizations/{self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id}"
console.print(
    Panel(
        f"[bold green]✅ Staging created:[/bold green]\n[link={staging_url}]{staging_url}[/link]",

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Disambiguate f-string conditional

Parentheses the conditional expression to avoid precedence confusion inside the
f-string. This prevents accidental string concatenation errors if exp_type is not a
string.

codeflash/optimization/function_optimizer.py [1478]

-staging_url = f"{CFAPI_BASE_URL}/review-optimizations/{self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id}"
+staging_url = f"{CFAPI_BASE_URL}/review-optimizations/{(self.function_trace_id[:-4] + exp_type) if self.experiment_id else self.function_trace_id}"
Suggestion importance[1-10]: 6

__

Why: Adding parentheses clarifies precedence and guards against type issues with exp_type, improving robustness with minimal change; impact is modest but sound.

Low
Normalize API base URL

Ensure CFAPI_BASE_URL does not include a trailing slash to prevent double slashes in
constructed URLs. Normalize the base URL locally before using it in f-strings.

codeflash/optimization/function_optimizer.py [23]

 from codeflash.api.cfapi import CFAPI_BASE_URL, add_code_context_hash, create_staging, mark_optimization_success
 
+CFAPI_BASE_URL = CFAPI_BASE_URL.rstrip("/")
+
Suggestion importance[1-10]: 5

__

Why: Normalizing CFAPI_BASE_URL can prevent double slashes in URLs and is low risk, but the PR does not show any actual issue and such normalization might be better handled at the source; moderate maintainability improvement.

Low

@misrasaurabh1 misrasaurabh1 merged commit 07417ba into main Oct 17, 2025
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants