fix: update performance tests counter to use camelCase API Key#7870
fix: update performance tests counter to use camelCase API Key#7870Sumedh-6504 wants to merge 5 commits into
Conversation
Signed-off-by: Sumedh-6504 <sumedhrmundewadi@gmail.com>
|
@rishiraj38 @KatalKavya96 The reason behind that I could not make a video is this, http://localhost:8000 is restricted from the CORS. So now you can actually review the code change. |
|
🚀 Preview deployment: https://layer5.io/pr-preview/pr-7870/
|
📝 WalkthroughWalkthroughThe changes update performance-count fetching to support two response field names and log failures. They also add a zero-count fallback for integrations, adjust Sistent template structure, and reformat JSX, styling, theme logic, and render hooks without changing most existing behavior. ChangesSite updates
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/sections/Counters/index.js`:
- Around line 15-21: Standardize performance-count parsing by introducing one
shared helper that prefers totalRuns, falls back to total_runs with nullish
coalescing, and preserves valid zero values. Update the fetch consumers in
src/sections/Counters/index.js, src/sections/Meshery/Features-Col/index.js,
src/sections/Meshery/How-meshery-works/specs/data-card.js, and
src/sections/Projects/Nighthawk/index.js to use that helper, including replacing
Features-Col’s 250000 non-OK fallback so all sections share the same contract.
In `@src/templates/sistent-component.js`:
- Around line 41-43: Remove the inner h1 rendered by the component around
displayName in the template, since SistentLayout already provides the page-level
heading. Preserve the description paragraph and ensure the rendered page retains
exactly one semantic h1.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: cb21e8ca-6b18-4486-9c19-98be76af5679
📒 Files selected for processing (9)
onRenderBody.jssrc/components/MeetInfo-Table/index.jssrc/sections/Counters/index.jssrc/sections/Meshery/Features-Col/data/index.jssrc/sections/Meshery/Features-Col/index.jssrc/sections/Meshery/How-meshery-works/specs/data-card.jssrc/sections/Projects/Nighthawk/index.jssrc/templates/sistent-component.jssrc/theme/app/ThemeManager.js
| .then((response) => response.json()) | ||
| .then((result) => | ||
| setPerformanceCount(result.totalRuns || result.total_runs), | ||
| ) | ||
| .catch((error) => { | ||
| console.error("Failed to fetch performance count:", error.message); | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== File list ==\n'
git ls-files 'src/sections/Counters/index.js' \
'src/sections/Meshery/Features-Col/index.js' \
'src/sections/Meshery/How-meshery-works/specs/data-card.js' \
'src/sections/Projects/Nighthawk/index.js'
printf '\n== Relevant excerpts ==\n'
for f in \
src/sections/Counters/index.js \
src/sections/Meshery/Features-Col/index.js \
src/sections/Meshery/How-meshery-works/specs/data-card.js \
src/sections/Projects/Nighthawk/index.js
do
echo "--- $f"
nl -ba "$f" | sed -n '1,220p'
doneRepository: layer5io/layer5
Length of output: 444
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
files = [
Path("src/sections/Counters/index.js"),
Path("src/sections/Meshery/Features-Col/index.js"),
Path("src/sections/Meshery/How-meshery-works/specs/data-card.js"),
Path("src/sections/Projects/Nighthawk/index.js"),
]
for path in files:
text = path.read_text()
print(f"\n== {path} ==")
for needle in ["fetch(", "response.ok", "totalRuns", "total_runs", "setPerformanceCount", "250000", "0 if fetch fails"]:
if needle in text:
print(f"contains: {needle}")
PYRepository: layer5io/layer5
Length of output: 772
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,220p' src/sections/Counters/index.js
printf '\n----\n'
sed -n '1,220p' src/sections/Meshery/Features-Col/index.js
printf '\n----\n'
sed -n '1,220p' src/sections/Meshery/How-meshery-works/specs/data-card.js
printf '\n----\n'
sed -n '1,220p' src/sections/Projects/Nighthawk/index.jsRepository: layer5io/layer5
Length of output: 17078
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
files = [
"src/sections/Counters/index.js",
"src/sections/Meshery/Features-Col/index.js",
"src/sections/Meshery/How-meshery-works/specs/data-card.js",
"src/sections/Projects/Nighthawk/index.js",
]
for f in files:
text = Path(f).read_text().splitlines()
print(f"\n== {f} ==")
for i, line in enumerate(text, 1):
if any(key in line for key in ["performanceCount", "250000", "totalRuns", "total_runs", "fetch(", "response.ok"]):
start = max(1, i-2)
end = min(len(text), i+2)
print(f"-- lines {start}-{end}")
for j in range(start, end+1):
print(f"{j:4d}: {text[j-1]}")
PYRepository: layer5io/layer5
Length of output: 4551
Standardize the performance-count fallback across these callers.
src/sections/Counters/index.js,src/sections/Meshery/How-meshery-works/specs/data-card.js, andsrc/sections/Projects/Nighthawk/index.jsuseresult.totalRuns || result.total_runs, which drops a valid0and can setperformanceCounttoundefined.src/sections/Meshery/Features-Col/index.jsuses a different non-OK fallback (250000), so the same metric renders inconsistently in this section.
Use ?? and one shared parser/helper so every consumer follows the same contract.
📍 Affects 4 files
src/sections/Counters/index.js#L15-L21(this comment)src/sections/Meshery/Features-Col/index.js#L96-L105src/sections/Meshery/How-meshery-works/specs/data-card.js#L50-L57src/sections/Projects/Nighthawk/index.js#L27-L34
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/sections/Counters/index.js` around lines 15 - 21, Standardize
performance-count parsing by introducing one shared helper that prefers
totalRuns, falls back to total_runs with nullish coalescing, and preserves valid
zero values. Update the fetch consumers in src/sections/Counters/index.js,
src/sections/Meshery/Features-Col/index.js,
src/sections/Meshery/How-meshery-works/specs/data-card.js, and
src/sections/Projects/Nighthawk/index.js to use that helper, including replacing
Features-Col’s 250000 non-OK fallback so all sections share the same contract.
| <h1>{displayName}</h1> | ||
| {frontmatter.description && <p>{frontmatter.description}</p>} | ||
| </div> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Avoid adding a second page-level heading.
SistentLayout already renders an <h1> at Line 8-23, so this new heading creates duplicate page titles for users and assistive technologies. Remove the inner <h1> or move the description into SistentLayout while retaining a single page heading.
As per coding guidelines, rendered JSX must meet WCAG 2.1 Level AA accessibility requirements and use semantic HTML.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/templates/sistent-component.js` around lines 41 - 43, Remove the inner h1
rendered by the component around displayName in the template, since
SistentLayout already provides the page-level heading. Preserve the description
paragraph and ensure the rendered page retains exactly one semantic h1.
Source: Coding guidelines
Description
This PR fixes #7860
Notes for Reviewers
Description
Fixes the performance test run counters displaying as
0across several pages (Meshery page, Nighthawk page, etc.) due to an API response key mismatch. Additionally resolves an ESLint warning insistent-component.jsthat was blocking the pre-commit checks.Root Cause
https://cloud.layer5.io/api/performance/results/totalreturns{"totalRuns": 160375}. However, the components were expectingresult.total_runs(snake_case) instead ofresult.totalRuns(camelCase). Since the snake_case key was undefined, the counter fell back to the initial state of0.isDarkdeclared but never used insistent-component.js) which blocked the pre-commit hooks due to--max-warnings=0constraints.Changes Made
src/sections/Counters/index.js— Updated key parsing to supporttotalRuns || total_runsand added a.catch()block with error logging.src/sections/Meshery/How-meshery-works/specs/data-card.js— Updated key parsing and added error handling (rendered on/cloud-native-management/meshery).src/sections/Projects/Nighthawk/index.js— Updated key parsing and added error handling (rendered on/projects/nighthawk).src/sections/Meshery/Features-Col/index.js— Updated key parsing and changedconsole.logtoconsole.errorin the catch block for consistency.src/templates/sistent-component.js— Removed the unusedisDarkvariable and its unused import to satisfy ESLint constraints and allow pre-commit hooks to pass successfully.Local Testing & CORS Restriction
Important
The performance test run count will still show
0(or log a CORS warning) onlocalhost:8000. The API endpoint restricts CORS requests to the production origin (layer5.io), meaning the browser blocks network requests originating from localhost. The fix is verified to match the production API payload structure and will render correctly once deployed to the production or preview environment.Screenshots
Signed commits
Summary by CodeRabbit
New Features
Bug Fixes