Skip to content

Release 1.0.0 - #4

Merged
kiranharidas187 merged 7 commits into
ELEVATE-Project:release-1.0.0from
darshilbabel:release-1.0.0
Jun 15, 2026
Merged

Release 1.0.0#4
kiranharidas187 merged 7 commits into
ELEVATE-Project:release-1.0.0from
darshilbabel:release-1.0.0

Conversation

@KUNALTEMPEST

@KUNALTEMPEST KUNALTEMPEST commented Jun 15, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added authentication token support throughout chat processing pipeline
    • Implemented language-specific error messaging for improved localization
    • Enhanced user profile updates with better field mapping
  • Improvements

    • Improved text-to-speech handling for markdown-formatted content
    • Added support for vernacular messages to optimize translation flows

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@KUNALTEMPEST, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 12 minutes and 39 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4ccb314-2810-49f7-9636-13464b6b54fd

📥 Commits

Reviewing files that changed from the base of the PR and between 499b8f0 and ed85489.

📒 Files selected for processing (4)
  • chatbot/celery_tasks/handle_message.py
  • chatbot/services/response_handlers/base_response_handler.py
  • chatbot/utils/audio_provider_utils.py
  • chatbot/utils/elevate/profile_utils.py
📝 Walkthrough

Walkthrough

The PR propagates a WebSocket access_token through the Celery task, orchestrator, and response handler to trigger a PATCH call to the Elevate profile update endpoint. It also adds vernacular-aware error message selection (bypassing translation for already-localized errors) across base and common response handlers, and introduces a markdown-stripping utility for text-to-speech input.

Changes

Access Token + Vernacular Error Handling + TTS Markdown Stripping

Layer / File(s) Summary
Access token propagation: WebSocket → Task → Orchestrator
chatbot/consumers/async_consumer.py, chatbot/celery_tasks/flow_tasks.py, chatbot/services/core/orchestrator.py
Consumer stores access_token from authenticate messages and passes it to get_flow_response.delay(...). The Celery task and ChatOrchestrator.process_chat_request both gain an optional access_token parameter, which is inserted into response_params for the bot strategy.
Elevate profile utilities: field mapping fixes and update_elevate_profile
chatbot/utils/elevate/profile_utils.py
handle_elevate_profile switches to userRole/userSchool/profileState/userDistrict keys and persists school_name to org_associated. New update_elevate_profile sends a PATCH to the Elevate /user/update endpoint using an access-token header.
Access token forwarded to Elevate update in context save
chatbot/services/response_handlers/common_handler.py (lines 821–887)
_handle_profile_tool_response reads access_token from tool kwargs and passes it to _save_submitted_user_context. When present, the helper calls update_elevate_profile with submitted profile fields plus district/state.
Vernacular error helper and base handler propagation
chatbot/services/response_handlers/base_response_handler.py
Adds get_error_message(company_bot, language) returning a BotVernacular.error_message or the default. handle_response sets is_bot_vernacular_message from _is_vernacular_error. Tool-loop retry and max-iteration paths return vernacular error messages and emit _is_vernacular_error in extra content.
Common handler: vernacular error replacement and flag forwarding
chatbot/services/response_handlers/common_handler.py
Replaces direct BotVernacular DB lookups with get_error_message(...) in EVENT_DATE, _send_db_question, process_response, and FREE_FLOW error paths. _handle_regular_response forwards is_bot_vernacular_message from kwargs to translate_message.
Translation bypass for vernacular messages
chatbot/celery_tasks/handle_message.py, chatbot/services/response_handlers/base_response_handler.py (lines 1049–1060)
translate_message gains is_bot_vernacular_message and forwards it to translate_and_send_message, which skips the translation provider and uses the message directly when the flag is set.
TTS markdown stripping
chatbot/utils/audio_provider_utils.py
New strip_markdown_for_tts(text) applies regex-based removal of code blocks, images, links, headings, HTML, and bullets. text_speech_provider preprocesses input through this function before synthesis.

Sequence Diagram(s)

sequenceDiagram
  participant WebSocket as AsyncConsumer (WebSocket)
  participant Task as get_flow_response (Celery)
  participant Orch as ChatOrchestrator
  participant Handler as CommonResponseHandler
  participant ElevateAPI as Elevate /user/update

  WebSocket->>WebSocket: store access_token from authenticate msg
  WebSocket->>Task: delay(..., access_token=self.access_token)
  Task->>Orch: process_chat_request(..., access_token=access_token)
  Orch->>Handler: get_response(response_params incl. access_token)
  Handler->>Handler: _handle_profile_tool_response reads access_token from kwargs
  Handler->>Handler: _save_submitted_user_context(profile_id, args, access_token)
  Handler->>ElevateAPI: PATCH /user/update with access_token header + profile fields
  ElevateAPI-->>Handler: updated profile JSON
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • ELEVATE-Project/saathi-backend#3: Modifies translate_and_send_message and introduces _translate_chips for chip translation in handle_message.py, directly overlapping with this PR's translation bypass and is_bot_vernacular_message additions in the same function.

Poem

🐇 Hop hop, the token flows from socket to the cloud,
Vernacular errors speak their language, no translation crowd.
The markdown strips away for ears that need plain speech,
Elevate gets patched when context fields are each in reach.
A rabbit wired it all with care, no field left out of sight! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.37% 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 'Release 1.0.0' is vague and generic, using a non-descriptive term that fails to convey meaningful information about the specific technical changes in the changeset. Consider a more descriptive title that highlights key improvements, such as 'Add vernacular error handling, TTS formatting, and profile update API' to better communicate the main changes.
✅ 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@KUNALTEMPEST

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
chatbot/utils/elevate/profile_utils.py (2)

17-17: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing timeout on requests.get call in handle_elevate_profile.

Similar to the PATCH call, the GET request on line 17 also lacks a timeout parameter.

⏱️ Proposed fix
-        response = requests.get(url=url, headers=headers)
+        response = requests.get(url=url, headers=headers, timeout=30)
🤖 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 `@chatbot/utils/elevate/profile_utils.py` at line 17, The requests.get() call
in the handle_elevate_profile function is missing a timeout parameter, which can
cause requests to hang indefinitely. Add a timeout parameter to the
requests.get(url=url, headers=headers) call to ensure the request completes
within a reasonable time frame, similar to how timeout should be handled for
other network requests in this function.

71-71: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Hardcoded plaintext password is a security risk.

The password "grit@123" is hardcoded in the profile creation. This creates security concerns: weak password visible in source control, same password for all Elevate-sourced profiles, and potential credential exposure in logs/error messages.

Consider using environment variables or generating random temporary passwords.

🔒 Proposed fix using environment variable or random password
+import secrets
+import string
+
+def _generate_temp_password():
+    """Generate a random temporary password."""
+    alphabet = string.ascii_letters + string.digits
+    return ''.join(secrets.choice(alphabet) for _ in range(16))
+
 # In the update_or_create call:
-                'password': "grit@123",
+                'password': os.getenv('ELEVATE_DEFAULT_PASSWORD') or _generate_temp_password(),
🤖 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 `@chatbot/utils/elevate/profile_utils.py` at line 71, Replace the hardcoded
plaintext password string "grit@123" in the profile creation dictionary (line
71) with a secure alternative. Either retrieve the password from an environment
variable using appropriate environment variable loading utilities, or generate a
random temporary password using a secure password generation method. Ensure the
solution does not expose credentials in logs or version control and avoids using
the same weak password across all Elevate-sourced profiles.
chatbot/consumers/async_consumer.py (1)

168-182: ⚠️ Potential issue | 🔴 Critical

Remove print statements logging sensitive authentication data and fix JWT algorithm mismatch.

Lines 168 and 176 print the raw access token and decoded JWT payload to stdout. In production, these will expose authentication credentials in application logs. Additionally, algorithms=["HS256"] with PUBLIC_KEY is cryptographically incorrect—HS256 is a symmetric algorithm requiring a shared secret, while PUBLIC_KEY indicates an asymmetric setup that should use RS256 or ES256.

🔒 Proposed fix
         if access_token:
-            print("Access Token: ", access_token)
+            logger.debug("Access token received (length=%d)", len(access_token) if access_token else 0)

             try:
                 decoded = jwt.decode(
                     access_token,
                     PUBLIC_KEY,
-                    algorithms=["HS256"]
+                    algorithms=["RS256"]
                 )
-                print("Decoded JWT: ", decoded)
+                logger.debug("JWT decoded successfully, user_id present: %s", bool(decoded.get("data", {}).get("id")))
                 if decoded:
                     user_id = decoded.get("data", {}).get("id")
             except Exception as e:
                 logger.error('JWT Decode Error: %s', e, exc_info=True)
-                print(f"JWT Decode Error: {e}")
🤖 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 `@chatbot/consumers/async_consumer.py` around lines 168 - 182, Remove the print
statements that expose sensitive authentication credentials to stdout in the JWT
decoding logic. Specifically, remove the print statement that outputs the raw
access_token directly and the print statement in the exception handler that logs
JWT decode errors. Additionally, fix the JWT algorithm mismatch by changing the
algorithm parameter from HS256 to RS256 or ES256 (whichever matches your key
setup), since HS256 is a symmetric algorithm but PUBLIC_KEY indicates an
asymmetric cryptographic setup. The jwt.decode call should use an algorithm that
corresponds to the type of key being used for verification.
🤖 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 `@chatbot/celery_tasks/handle_message.py`:
- Around line 44-46: In the logger.info call within the conditional block
checking if route is not 'en', remove the unnecessary f prefix from the string
since the logging uses %s formatting rather than f-string placeholders.
Additionally, fix the apparent typo where "date" appears in the log message—this
word seems out of place in the context of logging a target_language_code and
should be corrected to a more appropriate term or removed entirely.

In `@chatbot/services/response_handlers/base_response_handler.py`:
- Around line 32-40: In the get_error_message method, replace the bare except
Exception pass statement with proper logging. Use a logger (import it if needed)
to log the exception at an appropriate level such as warning or error, while
maintaining the existing fallback behavior that returns the default error
message. This ensures database connectivity issues and query failures are
captured for debugging without changing the method's functionality.

In `@chatbot/utils/audio_provider_utils.py`:
- Around line 25-26: In the early return check around lines 25-26, replace the
direct return of the raw falsy input with a normalized safe string value. When
the text parameter is falsy (None, empty string, etc.), return an empty string
instead of the raw text variable. This ensures that all downstream TTS provider
calls receive a guaranteed string type rather than potentially receiving None,
preventing runtime failures when users provide invalid or missing input to the
text-to-speech functionality.
- Line 99: Remove the debug print statement `print("Strip text: ", text)` from
the code as it logs raw user-provided content to stdout, which can expose PII or
sensitive data in production logs. Simply delete this line entirely to prevent
unintended information leakage through standard output.

In `@chatbot/utils/elevate/profile_utils.py`:
- Around line 137-140: The requests.patch call in the update_elevate_profile
function lacks a timeout parameter, which can cause indefinite blocking if the
Elevate service is unresponsive and exhaust the Celery worker pool. Add a
timeout parameter (e.g., timeout=30) to the requests.patch call to ensure the
request fails fast rather than hanging indefinitely.
- Line 125: The hardcoded placeholder string `'please get hardcode the about'`
assigned to the `'about'` key in the `body` dictionary is a development
placeholder that will be visible to users and is confusing. Either remove the
`'about'` field entirely from the dictionary or replace it with a meaningful
default value that provides useful information to users viewing profiles on the
Elevate system.

---

Outside diff comments:
In `@chatbot/consumers/async_consumer.py`:
- Around line 168-182: Remove the print statements that expose sensitive
authentication credentials to stdout in the JWT decoding logic. Specifically,
remove the print statement that outputs the raw access_token directly and the
print statement in the exception handler that logs JWT decode errors.
Additionally, fix the JWT algorithm mismatch by changing the algorithm parameter
from HS256 to RS256 or ES256 (whichever matches your key setup), since HS256 is
a symmetric algorithm but PUBLIC_KEY indicates an asymmetric cryptographic
setup. The jwt.decode call should use an algorithm that corresponds to the type
of key being used for verification.

In `@chatbot/utils/elevate/profile_utils.py`:
- Line 17: The requests.get() call in the handle_elevate_profile function is
missing a timeout parameter, which can cause requests to hang indefinitely. Add
a timeout parameter to the requests.get(url=url, headers=headers) call to ensure
the request completes within a reasonable time frame, similar to how timeout
should be handled for other network requests in this function.
- Line 71: Replace the hardcoded plaintext password string "grit@123" in the
profile creation dictionary (line 71) with a secure alternative. Either retrieve
the password from an environment variable using appropriate environment variable
loading utilities, or generate a random temporary password using a secure
password generation method. Ensure the solution does not expose credentials in
logs or version control and avoids using the same weak password across all
Elevate-sourced profiles.
🪄 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

Run ID: 47d06eee-93bb-417b-bd97-f0e26bd600f2

📥 Commits

Reviewing files that changed from the base of the PR and between 2491f60 and 499b8f0.

📒 Files selected for processing (8)
  • chatbot/celery_tasks/flow_tasks.py
  • chatbot/celery_tasks/handle_message.py
  • chatbot/consumers/async_consumer.py
  • chatbot/services/core/orchestrator.py
  • chatbot/services/response_handlers/base_response_handler.py
  • chatbot/services/response_handlers/common_handler.py
  • chatbot/utils/audio_provider_utils.py
  • chatbot/utils/elevate/profile_utils.py

Comment thread chatbot/celery_tasks/handle_message.py Outdated
Comment thread chatbot/services/response_handlers/base_response_handler.py
Comment thread chatbot/utils/audio_provider_utils.py
Comment thread chatbot/utils/audio_provider_utils.py Outdated

def text_speech_provider(company_bot, text, source_language):
text = strip_markdown_for_tts(text)
print("Strip text: ", text)

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 raw user-text debug print to avoid sensitive data leakage.

At Line 99, print("Strip text: ", text) logs user-provided content to stdout. This can expose PII/content in production logs and should be removed (or replaced with non-content telemetry only).

Suggested fix
-    print("Strip text: ", text)
+    logger.debug("TTS input sanitized successfully")
🤖 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 `@chatbot/utils/audio_provider_utils.py` at line 99, Remove the debug print
statement `print("Strip text: ", text)` from the code as it logs raw
user-provided content to stdout, which can expose PII or sensitive data in
production logs. Simply delete this line entirely to prevent unintended
information leakage through standard output.

Comment thread chatbot/utils/elevate/profile_utils.py
Comment thread chatbot/utils/elevate/profile_utils.py
@KUNALTEMPEST

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kiranharidas187
kiranharidas187 merged commit fc76db8 into ELEVATE-Project:release-1.0.0 Jun 15, 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