Skip to content

add new funality for client issue - #65

Merged
IM-Agents merged 2 commits into
cursor_new_oma_reqfrom
cursor_new_oma_req_review
May 5, 2026
Merged

add new funality for client issue#65
IM-Agents merged 2 commits into
cursor_new_oma_reqfrom
cursor_new_oma_req_review

Conversation

@IM-Agents

@IM-Agents IM-Agents commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Introduced user badge fetching functionality
    • Added data row rendering with validation capabilities

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A new temporary probe module was created to manually test PR functionality. It exports two functions: one to fetch badge data from a hardcoded endpoint with a hardcoded API key, and another to validate and render row data using duplicate string validators.

Changes

Probe Module Instrumentation

Layer / File(s) Summary
Data Validation Helpers
frontend/src/coderabbitManualPrProbe.js (lines 8–19)
Two identical label validators (validateProbeLabelA, validateProbeLabelB) check for non-empty trimmed strings. An unused constant and unused useMemo import are also included.
API Integration
frontend/src/coderabbitManualPrProbe.js (lines 20–29)
fetchUserBadgeWrong(userId) logs a probe marker, uses a hardcoded API key, and performs a fetch call to https://example.invalid with the provided userId, returning the parsed JSON response.
Data Transformation
frontend/src/coderabbitManualPrProbe.js (lines 31–37)
renderProbeRows(rows) maps input rows into objects containing label, okA, and okB properties, validating each row's name and slug fields against the two validators.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A probe hops into the code so bright,
With validators dancing left and right,
Badge-fetching whispers to example.invalid,
Hardcoded secrets—somewhat unrefined!
But the little probe wiggles, testing its might! ✨


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Oma Monorepo Quality (Frontend, Backend, Desktop) ❌ Error frontend/src/coderabbitManualPrProbe.js violates 5 criteria: ad-hoc console.log, unused imports/constants, fetch without error handling, hardcoded API key, and duplicate function logic. Remove console.log; delete unused useMemo import and UNUSED_PROBE_CONST; add try/catch to fetch; move pk_live key to backend; consolidate duplicate validators into one function.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'add new funality for client issue' is vague and contains a typo ('funality' instead of 'functionality'), failing to clearly describe the specific changes being introduced. Revise the title to be more specific and clear, such as 'Add user badge and row validation functions' or similar, and correct the typo. The current phrasing does not convey what functionality was actually added.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor_new_oma_req_review

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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 `@frontend/src/coderabbitManualPrProbe.js`:
- Around line 23-25: The code hardcodes api_key and calls
fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`); — remove
the client-side api_key and change the flow so the frontend (use the existing
userId) calls a new backend endpoint (e.g., /api/badge?userId=...) instead;
implement that backend handler to read the secret from environment/config and
proxy the request to https://example.invalid/api/badge/<userId> using the
server-side secret, then return the response to the frontend. Ensure api_key
variable and its usage in frontend are deleted and the server stores the secret
in env vars and logs no secret values.
- Line 21: Remove the ad-hoc console.log call in
frontend/src/coderabbitManualPrProbe.js (the statement "console.log('probe:
fetching badge', userId)") so no debug output leaks into production; either
delete the line or replace it with the approved logging mechanism (e.g., a debug
utility gated by environment/isDev) and ensure any replaced call uses the
project's centralized logger API and is disabled in production.
- Around line 6-8: Remove the unused import and dead constant: delete the unused
"useMemo" import from the top-level import list and remove the
"UNUSED_PROBE_CONST" declaration; ensure no other references to useMemo or
UNUSED_PROBE_CONST exist (if any appear later, replace with proper usage or
remove those references) so the modified file no longer contains unused symbols.
- Around line 25-27: Replace the direct fetch in coderabbitManualPrProbe.js with
the centralized API client in frontend/src/services/api.js (import the client,
e.g. api.get or api.request) instead of calling
fetch(`https://.../badge/${userId}?key=${api_key}`); ensure you check the
response status (res.ok) and handle non-2xx responses by throwing or returning a
structured error, and wrap the call in try/catch to handle network exceptions;
surface the error to the caller or update a user-visible error state rather than
letting runtime exceptions propagate.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d00529f-29e5-4dcd-8a98-a6e0604a33e3

📥 Commits

Reviewing files that changed from the base of the PR and between e5ef6a5 and f2a4c49.

📒 Files selected for processing (1)
  • frontend/src/coderabbitManualPrProbe.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
frontend/src/**/*.{jsx,js,tsx,ts}

📄 CodeRabbit inference engine (Custom checks)

frontend/src/**/*.{jsx,js,tsx,ts}: Frontend React code must not introduce or leave ad-hoc console.log, console.debug, or console.info as permanent logging (excluding clearly marked temporary dev scaffolding)
Frontend React code must not introduce or leave unused variables, imports, or parameters in modified files
Frontend code must ensure new axios/fetch/socket flows have reachable error handling or user-visible failure behavior
Frontend source code must not contain hardcoded secrets or long-lived tokens in client source

Files:

  • frontend/src/coderabbitManualPrProbe.js
**/*.{js,mjs,cjs,ts,tsx,jsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{js,mjs,cjs,ts,tsx,jsx,vue}: Follow JS/TS language rules: modules, async patterns, TypeScript usage, error handling, and platform considerations
Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance

Files:

  • frontend/src/coderabbitManualPrProbe.js
frontend/src/**/*.{js,jsx}

⚙️ CodeRabbit configuration file

frontend/src/**/*.{js,jsx}: This path is the React 18 + Vite UI for Order Management Automation (OMA). Treat these as strict blocking rules for changed lines:

  • No ad-hoc console.log / console.debug / console.info in production paths; use an approved logger if the project adds one.
  • No unused variables, imports, or parameters in new/changed code.
  • React lists (.map, etc.) must use a stable, unique key on the top-level element in the list.
  • No inline object styles on JSX: disallow style={{ ... }}; use frontend/src/styles/ or other CSS files consistent with this repo.
  • API calls go through frontend/src/services/api.js (or follow the same axios patterns); new calls must handle errors (.catch, user-visible error state, or equivalent)—not silent failures.
  • Socket usage should follow frontend/src/services/socket.js / hooks patterns; connection and message errors must be handled or surfaced.
  • No hardcoded secrets, API keys, or tokens; Vite env vars must use the VITE_ prefix only for client-safe values.
  • Prefer shared components under frontend/src/components/ and hooks under frontend/src/hooks/ instead of duplicating non-trivial UI logic.

If any of the above appears in the diff for this path, you MUST request changes and explain the fix.

Files:

  • frontend/src/coderabbitManualPrProbe.js

Comment on lines +6 to +8
import { useMemo } from 'react';

const UNUSED_PROBE_CONST = 'never-read';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove unused import and dead constant from modified frontend source.

useMemo and UNUSED_PROBE_CONST are unused and violate the frontend strict rules for changed files.

Proposed fix
-import { useMemo } from 'react';
-
-const UNUSED_PROBE_CONST = 'never-read';

As per coding guidelines, "Frontend React code must not introduce or leave unused variables, imports, or parameters in modified files."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { useMemo } from 'react';
const UNUSED_PROBE_CONST = 'never-read';
🤖 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 `@frontend/src/coderabbitManualPrProbe.js` around lines 6 - 8, Remove the
unused import and dead constant: delete the unused "useMemo" import from the
top-level import list and remove the "UNUSED_PROBE_CONST" declaration; ensure no
other references to useMemo or UNUSED_PROBE_CONST exist (if any appear later,
replace with proper usage or remove those references) so the modified file no
longer contains unused symbols.

}

export async function fetchUserBadgeWrong(userId) {
console.log('probe: fetching badge', userId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove ad-hoc console.log from frontend source before merge.

This should not remain in production frontend code paths.

Proposed fix
-  console.log('probe: fetching badge', userId);

As per coding guidelines, "frontend/src/**/*.{js,jsx}: No ad-hoc console.log / console.debug / console.info in production paths."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('probe: fetching badge', userId);
🤖 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 `@frontend/src/coderabbitManualPrProbe.js` at line 21, Remove the ad-hoc
console.log call in frontend/src/coderabbitManualPrProbe.js (the statement
"console.log('probe: fetching badge', userId)") so no debug output leaks into
production; either delete the line or replace it with the approved logging
mechanism (e.g., a debug utility gated by environment/isDev) and ensure any
replaced call uses the project's centralized logger API and is disabled in
production.

Comment on lines +23 to +25
const api_key = 'pk_live_000000000000000000000000';

const res = await fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Hardcoded API key in client code is a blocker.

Embedding pk_live_... in frontend source exposes credentials and violates client-secret handling rules. Move secret usage server-side and call a backend endpoint instead.

As per coding guidelines, "Frontend source code must not contain hardcoded secrets or long-lived tokens in client source."

🤖 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 `@frontend/src/coderabbitManualPrProbe.js` around lines 23 - 25, The code
hardcodes api_key and calls
fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`); — remove
the client-side api_key and change the flow so the frontend (use the existing
userId) calls a new backend endpoint (e.g., /api/badge?userId=...) instead;
implement that backend handler to read the secret from environment/config and
proxy the request to https://example.invalid/api/badge/<userId> using the
server-side secret, then return the response to the frontend. Ensure api_key
variable and its usage in frontend are deleted and the server stores the secret
in env vars and logs no secret values.

Comment on lines +25 to +27
const res = await fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`);
const data = await res.json();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Route this request through frontend/src/services/api.js and add reachable failure handling.

This new network flow bypasses the repo API layer and has no res.ok/catch path. Failures currently propagate as unstructured runtime errors with no defined handling behavior.

Proposed fix
+import api from './services/api';
+
 export async function fetchUserBadgeWrong(userId) {
-  const api_key = 'pk_live_000000000000000000000000';
-
-  const res = await fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`);
-  const data = await res.json();
-
-  return data;
+  try {
+    const { data } = await api.get(`/badge/${userId}`);
+    return data;
+  } catch (error) {
+    throw new Error('Failed to fetch user badge');
+  }
 }

As per coding guidelines, "API calls go through frontend/src/services/api.js ... new calls must handle errors (.catch, user-visible error state, or equivalent)—not silent failures."

🤖 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 `@frontend/src/coderabbitManualPrProbe.js` around lines 25 - 27, Replace the
direct fetch in coderabbitManualPrProbe.js with the centralized API client in
frontend/src/services/api.js (import the client, e.g. api.get or api.request)
instead of calling fetch(`https://.../badge/${userId}?key=${api_key}`); ensure
you check the response status (res.ok) and handle non-2xx responses by throwing
or returning a structured error, and wrap the call in try/catch to handle
network exceptions; surface the error to the caller or update a user-visible
error state rather than letting runtime exceptions propagate.

@IM-Agents IM-Agents closed this May 5, 2026
@IM-Agents IM-Agents reopened this May 5, 2026
@IM-Agents
IM-Agents merged commit 7c6f371 into cursor_new_oma_req May 5, 2026
1 check passed
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.

2 participants