Skip to content

Conversation

@laibaishfaq108-blip
Copy link

@laibaishfaq108-blip laibaishfaq108-blip commented Jan 23, 2026

Summary

Added a simple Streamlit Translator demo app to the community directory.

Changes

  • Create translator app using Streamlit
  • Added app.py

Closes #[1761]

Summary by CodeRabbit

  • New Features

    • New Streamlit translator app with text input, automatic source language detection, and Translate/Clear actions; supports Urdu, Hindi, and Arabic with realtime translation display.
  • Documentation

    • Added a comprehensive README for the translator app with features, install and run instructions, usage, and contribution guidance.
    • Removed the top-level community README describing contribution processes and scope.
  • Chores

    • Added runtime dependencies for the app (Streamlit and related packages).

✏️ Tip: You can customize this high-level summary in your review settings.

@sumitsaurabh927
Copy link
Contributor

hi your PR is missing changeset. Please add the changeset by following instructions here. Make sure you've joined our discord to see this message. If you haven't you need to:

  1. Join our discord here
  2. Go through the instructions to add changeset and add it to your PR

Please also sign your commits

Lastly, your readme is a copy of the community space readme. It needs to be about your project 😀

Please update it.

@github-actions
Copy link
Contributor

Hey @laibaishfaq108-blip! Just checking in - are you still working on this PR? We noticed there are some comments that may need addressing. If you need more time, no problem! Just let us know. If we don't hear back within a week, we'll close this to keep the repo tidy, but you can always reopen when ready.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

Adds a new Streamlit translator app and its README and requirements; removes the top-level community/README.md. The app uses deep_translator's GoogleTranslator to translate user-provided text into selected target languages.

Changes

Cohort / File(s) Summary
New translator README
community/py-streamlit-translator/README.md
Added project README with overview, features, tech stack, installation, usage (streamlit run app.py), project structure, contribution, author, and support sections
Translator application
community/py-streamlit-translator/app.py
New Streamlit app: text input, language dropdown (Urdu/Hindi/Arabic → target codes), Translate/Clear buttons, uses GoogleTranslator(source="auto", target=...), shows spinner, displays translation in text area and code block, basic empty-input validation
Dependencies
community/py-streamlit-translator/requirements.txt
New requirements: streamlit, lingodotdev, python-dotenv
Removed top-level docs
community/README.md
Deleted existing community README content describing contribution guidelines and scope

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant App as Streamlit App
  participant GT as GoogleTranslator

  User->>App: Enter text + select language\nClick "Translate"
  App->>App: validate input\nshow spinner
  App->>GT: translate(text, target)
  GT-->>App: translation result
  App-->>User: display translation (text area + code block)\nshow success message
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped in bytes to help translate,

Words leapt fences, found a new state.
Urdu, Hindi, Arabic — a cheerful spree,
Streamlit sings the language-tree.
Hooray for apps that set words free!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It lacks key required sections including Testing, Visuals, and most Checklist items. Only Summary and partial Changes sections are provided. Complete the description by adding Testing section with test checkboxes, Visuals section for screenshots/demos, and filling out all Checklist items including changeset and breaking changes documentation.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new Streamlit Translator demo app to the community directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@community/py-streamlit-translator/app.py`:
- Around line 9-22: The Clear button currently calls st.rerun() which doesn't
reset the st.text_area and trying to set st.session_state after rendering will
raise a StreamlitAPIException; fix this by giving the text area a key (e.g.,
"input_text") via st.text_area(..., key="input_text") and implement a
clear_input callback (e.g., def clear_input(): st.session_state["input_text"] =
"") then attach it to the Clear button using st.button("Clear 🧹",
on_click=clear_input) so the widget state is cleared correctly; alternatively
consider using st.form with clear_on_submit=True for a submit-and-clear flow.
- Around line 23-31: Wrap the call to GoogleTranslator(...).translate(text) in a
try/except that specifically catches deep_translator.exceptions.TooManyRequests
and a general Exception, display a user-facing st.error like "Translation
failed. Please try again in a moment." (do not call st.stop()), and set
translated to None when an error occurs so the subsequent success/display block
only runs if translated is truthy; update the block referencing
GoogleTranslator, translated, and do_translate accordingly.

In `@community/py-streamlit-translator/README.md`:
- Around line 30-60: Update README.md to fix unbalanced code fences and make the
clone/install steps repo-specific: replace the placeholder git clone with the
monorepo URL and correct subfolder path (use git clone
https://github.com/lingodotdev/lingo.dev.git then cd
lingo.dev/community/py-streamlit-translator), wrap the Clone, Install
dependencies, and Run the app commands each in proper ```bash fenced blocks, and
ensure headings like "## 📂 Project Structure" and "## 🙌 Contribution" include
a space after the emoji for consistent markdown rendering; locate these edits in
the README.md content for py-streamlit-translator.

In `@community/py-streamlit-translator/requirements.txt`:
- Around line 1-3: requirements.txt is missing the deep-translator package
required by app.py (it imports deep_translator.GoogleTranslator); add the
dependency "deep-translator" to requirements.txt so the import
deep_translator.GoogleTranslator in app.py resolves at runtime and prevents
ImportError.
- Around line 1-3: The Streamlit dependency in requirements.txt pulls a protobuf
version in the vulnerable range; to mitigate, locate any codepaths that parse
protobuf JSON (search for usages of google.protobuf.json_format.ParseDict,
Parse, MessageToJson, or any code handling google.protobuf.Any) and replace
direct ParseDict calls with a safe wrapper that first validates input: enforce a
maximum JSON nesting depth, reject or strip Any fields, and disallow untrusted
JSON before calling protobuf parsers; add defensive checks where streamlit-based
components accept user JSON input and document/monitor
protocolbuffers/protobuf#25239 to upgrade protobuf to a patched release as soon
as it is published.
🧹 Nitpick comments (1)
community/py-streamlit-translator/README.md (1)

3-5: Align README with actual dependency and fix typo.

There’s a stray * at Line 3, and the Tech Stack lists googletrans even though the app uses deep_translator. This can confuse contributors about the actual dependency.

✏️ Suggested edits
-A simple and interactive Translator web app built using **Python + Streamlit**.*
+A simple and interactive Translator web app built using **Python + Streamlit**.

@@
-- deep-translator / googletrans
+- deep-translator (GoogleTranslator)

Also applies to: 21-24

Comment on lines +9 to +22
text = st.text_area("Write text", height=120, placeholder="e.g., Hello how are you?")

lang = st.selectbox("Translate to", ["Urdu", "Hindi", "Arabic"])
target_map = {"Urdu": "ur", "Hindi": "hi", "Arabic": "ar"}
target = target_map[lang]

col1, col2 = st.columns(2)
with col1:
do_translate = st.button("Translate ✅")
with col2:
clear = st.button("Clear 🧹")
if clear:
st.rerun()

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

❓ Verification inconclusive

Streamlit st.rerun widget state reset clear text input


To clear/reset a st.text_input when you call st.rerun(), you generally need to avoid trying to change the widget’s value after it’s already been rendered in the current run (Streamlit will block/ignore that pattern). (docs.streamlit.io)

Option A (recommended): put the input in a form and use clear_on_submit=True

This is the cleanest “clear after submit” behavior and works well with st.rerun() to refresh other UI. (docs.streamlit.io)

import streamlit as st

with st.form("my_form", clear_on_submit=True):
    q = st.text_input("Query")
    submitted = st.form_submit_button("Search")

if submitted:
    # do something with q
    st.rerun()

Option B: force a new widget identity by changing the key

Changing the key makes Streamlit treat it as a new widget, so it appears empty again. (This aligns with Streamlit’s widget identity/lifecycle rules.) (docs.streamlit.io)

import streamlit as st

st.session_state.setdefault("txt_ver", 0)
k = f"q_{st.session_state.txt_ver}"

q = st.text_input("Query", key=k)

if st.button("Clear"):
    st.session_state.txt_ver += 1
    st.rerun()

Option C: delete the session_state entry before rendering the widget

Deleting session state is supported, but make sure the deletion happens before the widget is created in that run. (docs.streamlit.io)

import streamlit as st

if st.session_state.get("do_clear"):
    st.session_state.pop("q", None)
    st.session_state.do_clear = False

q = st.text_input("Query", key="q")

if st.button("Clear"):
    st.session_state.do_clear = True
    st.rerun()

If you share a small snippet of your current code (especially where st.rerun() is called), I can point to the exact minimal change.

Citations:


Streamlit session_state widget key clear text_area


To clear an st.text_area that’s tied to st.session_state, you must update its key’s value before the widget is instantiated in the next rerun—typically via a callback (don’t set st.session_state[ta_key] = "" inside the if st.button(...): block after the widget renders, or you’ll hit StreamlitAPIException). [5], [3]

Pattern: use on_click/on_change callback to reset the widget key

import streamlit as st

TA_KEY = "msg"

def clear_text_area():
    st.session_state[TA_KEY] = ""

# Initialize (optional but common)
st.session_state.setdefault(TA_KEY, "")

st.button("Clear", on_click=clear_text_area)

st.text_area("Message", key=TA_KEY)

This works because callbacks run first, then Streamlit reruns the script top-to-bottom, and the widget reads the updated st.session_state[TA_KEY]. [1], [5], [3]

Alternative: force a reset by changing the widget key

If you change the widget’s key (e.g., add a counter suffix), Streamlit treats it as a new widget and it resets. [1]

Sources: Streamlit docs on widget behavior and button-driven resets [1], [5], session_state usage/limitations [2], and a working community example clearing text_area via callback [3].


Streamlit rerun behavior widget persistence state management


Streamlit’s execution model is: your script reruns top-to-bottom on (most) widget interactions, and you manage persistence via widget keys + st.session_state.

Reruns: what triggers them

  • Widgets outside a form: changing a value triggers an immediate rerun (for text/number inputs, typically on blur/tab-out or Enter). [1]
  • Widgets inside st.form(...): changes don’t reach Python and don’t rerun until the user submits the form (via st.form_submit_button). [1]

Widget state & callbacks: order of operations

On interaction, Streamlit updates state and reruns in this order:

  1. the widget value in st.session_state is updated
  2. the widget callback runs (if any)
  3. the script reruns, and the widget call returns the new value [2]

Persistence rules (the part that surprises people)

  • Widgets persist only if they are continuously rendered. If a widget isn’t called on a run (e.g., you hide it behind an if, switch pages, etc.), Streamlit drops its state—including its st.session_state[key] entry—and when it reappears it’s treated as a new widget. [2]
  • Browser refresh / full reload resets Session State, because it’s tied to the session’s WebSocket connection. [3]

Practical state-management patterns

  • Give widgets stable key= values so their values are tracked in st.session_state across reruns. (st.session_state[key] is the “source of truth” for that widget’s value.) [3]
  • Initialize non-widget state once:
    if "filters" not in st.session_state:
        st.session_state.filters = {}
    (Session State exists specifically because normal Python variables reset every rerun.) [4]
  • Use forms to “batch” multiple widget edits into one rerun on submit. [1]
  • Avoid trying to set a widget’s value in st.session_state after you’ve already instantiated that widget in the same run—Streamlit will raise an exception; set defaults before creating the widget, and then read/act on state afterward. [3]

If you describe your specific case (e.g., “a widget disappears when a checkbox is off” / “multipage app” / “I need values to survive refresh”), I can suggest the cleanest pattern for it.


Clear button doesn't actually clear widget state—and the suggested approach will fail.

st.rerun() alone won't reset st.text_area state; the previous input will persist. However, setting st.session_state after the widget has already rendered (as in the suggested fix) will raise a StreamlitAPIException. Instead, use a callback:

def clear_input():
    st.session_state["input_text"] = ""

text = st.text_area(
    "Write text",
    height=120,
    placeholder="e.g., Hello how are you?",
    key="input_text",
)

col1, col2 = st.columns(2)
with col1:
    do_translate = st.button("Translate ✅")
with col2:
    clear = st.button("Clear 🧹", on_click=clear_input)

Alternatively, use st.form with clear_on_submit=True for a cleaner "clear after submit" pattern.

🤖 Prompt for AI Agents
In `@community/py-streamlit-translator/app.py` around lines 9 - 22, The Clear
button currently calls st.rerun() which doesn't reset the st.text_area and
trying to set st.session_state after rendering will raise a
StreamlitAPIException; fix this by giving the text area a key (e.g.,
"input_text") via st.text_area(..., key="input_text") and implement a
clear_input callback (e.g., def clear_input(): st.session_state["input_text"] =
"") then attach it to the Clear button using st.button("Clear 🧹",
on_click=clear_input) so the widget state is cleared correctly; alternatively
consider using st.form with clear_on_submit=True for a submit-and-clear flow.

Comment on lines +23 to +31
if do_translate:
if text.strip() == "":
st.warning("Please write something first.")
else:
with st.spinner("Translating..."):
translated = GoogleTranslator(source="auto", target=target).translate(text)
st.success("Done!")
st.text_area("Translation", value=translated, height=120)
st.code(translated, language="text")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "app.py" | head -20

Repository: lingodotdev/lingo.dev

Length of output: 107


🏁 Script executed:

cd community/py-streamlit-translator 2>/dev/null && ls -la

Repository: lingodotdev/lingo.dev

Length of output: 357


🏁 Script executed:

cd community/py-streamlit-translator 2>/dev/null && cat -n app.py | head -50

Repository: lingodotdev/lingo.dev

Length of output: 1381


🌐 Web query:

GoogleTranslator google-translator-py exceptions raises errors

💡 Result:

GoogleTranslator is used by multiple Python packages, so the exact exceptions depend on which one you installed (the name google-translator-py is ambiguous). The most common ones people hit are:

  • Exception: Unexpected status code "429" (rate-limited / blocked) — happens with unofficial “scrape” clients; often indicates Google is throttling/banning your IP. Seen in googletrans/py-googletrans. [1]
  • HTTP 5xx / “banned client IP” symptomsgoogletrans explicitly warns that 5xx (and similar) can mean your client IP was banned. [2]
  • Async misuse warnings/errors — newer googletrans versions are async; calling Translator.translate() without await leads to runtime warnings and broken behavior. [3]
  • Library-specific “too many requests” exceptions — e.g., deep-translator’s ecosystem can raise TooManyRequests when providers throttle you. [4]
  • Old-version attribute errors — e.g., AttributeError: 'Translator' object has no attribute 'raise_Exception' occurred in older googletrans prereleases. [1]

If you paste (a) pip show google-translator-py output (or the exact package name/version) and (b) the full traceback, I can map your error to the exact exception type and the right fix.


🏁 Script executed:

cat community/py-streamlit-translator/requirements.txt

Repository: lingodotdev/lingo.dev

Length of output: 100


🌐 Web query:

deep_translator GoogleTranslator exceptions TooManyRequests documentation

💡 Result:

deep_translator documents a dedicated exception class for GoogleTranslator rate-limiting:

  • Exception: deep_translator.exceptions.TooManyRequests (a plain Exception subclass). It’s documented with the default message indicating Google rate limits (e.g., ~5 requests/sec and up to 200k/day) and suggests waiting/retrying or using translate_batch. [1]
  • When it’s raised (GoogleTranslator): when Google responds with HTTP 429 (rate limiting). [2]

Minimal usage:

from deep_translator import GoogleTranslator
from deep_translator.exceptions import TooManyRequests

try:
    GoogleTranslator(source="auto", target="en").translate("Hola")
except TooManyRequests as e:
    # backoff + retry, or switch to translate_batch / another provider
    print(e)

Sources: deep-translator exceptions docs [1] and GoogleTranslator error-handling notes [2].

References:
[1] (deep-translator.readthedocs.io)
[2] (deepwiki.com)

Citations:


🌐 Web query:

Streamlit st.stop() error handling best practice

💡 Result:

Best practice for handling st.stop() in Streamlit

  • Use st.stop() for control flow, not “error handling.” It’s meant for early-exit/guard clauses (e.g., missing input). Streamlit recommends you render a user-facing message first, then stop. [1]

    if not name:
        st.warning("Please enter a name.")
        st.stop()
  • Assume st.stop() works by raising an internal “stop” exception. Seeing something like streamlit.runtime.scriptrunner.exceptions.StopException can happen in debuggers/logs or if something intercepts it; it’s normal that stopping execution is implemented via an exception. [2]

  • Don’t accidentally catch it with broad exception handlers.

    • Avoid except BaseException: (or bare except:) around code that may call st.stop() (or other Streamlit control-flow like reruns), because you can swallow the control-flow signal and end up in a broken state.
    • If you must have a broad handler, re-raise Streamlit’s control-flow exceptions (stop/rerun) and only handle “real” errors.
  • Be extra careful with try/except around Streamlit control-flow. Streamlit has had version-specific edge cases where control-flow APIs misbehave inside try/except (documented for st.rerun in 1.37). Keeping st.stop() (and st.rerun) outside broad try/except blocks is the safest pattern. [3]

  • For “real” errors, prefer catching specific exceptions and showing UI, rather than sprinkling st.stop() everywhere. If you find yourself doing st.error(...); st.stop() repeatedly, consider centralizing error-to-UI handling (an “error boundary” style) to keep app logic clean. [4]

Sources: Streamlit st.stop docs [1]; Streamlit forum discussion of StopException from st.stop() [2]; Streamlit GitHub issue on control-flow inside try/except (st.rerun) [3]; community “error boundary” approach noting Streamlit control-flow exceptions should pass through [4].


Add error handling for GoogleTranslator API failures.

GoogleTranslator can raise deep_translator.exceptions.TooManyRequests (rate limiting) and other exceptions. The current code will crash if the API fails or is throttled. Add a try/except block, but avoid st.stop() inside the exception handler (Streamlit control-flow can misbehave). Instead, catch the exception, display an error message, and let the user retry.

🛡️ Suggested error handling
if do_translate:
    if text.strip() == "":
        st.warning("Please write something first.")
    else:
        with st.spinner("Translating..."):
            try:
                translated = GoogleTranslator(source="auto", target=target).translate(text)
            except Exception as e:
                st.error("Translation failed. Please try again in a moment.")
                translated = None
        
        if translated:
            st.success("Done!")
            st.text_area("Translation", value=translated, height=120)
            st.code(translated, language="text")
🤖 Prompt for AI Agents
In `@community/py-streamlit-translator/app.py` around lines 23 - 31, Wrap the call
to GoogleTranslator(...).translate(text) in a try/except that specifically
catches deep_translator.exceptions.TooManyRequests and a general Exception,
display a user-facing st.error like "Translation failed. Please try again in a
moment." (do not call st.stop()), and set translated to None when an error
occurs so the subsequent success/display block only runs if translated is
truthy; update the block referencing GoogleTranslator, translated, and
do_translate accordingly.

Comment on lines +30 to +60
Clone the repo:

```bash
git clone <your-repo-url>
cd py-streamlit-translator
Install dependencies:

**Bash**

pip install -r requirements.txt
Run the app:

**Bash**
streamlit run app.py

## 💻 Usage:

Enter text
Select source language
Select target language
Click Translate
Get instant results 🎉

##📂 Project Structure

py-streamlit-translator/
│── app.py
│── requirements.txt
│── README.md

##🙌 Contribution
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix markdown formatting and make install steps repo-specific.

The installation section’s code fences are unbalanced, and the placeholder repo URL conflicts with the monorepo structure. Also, headings like ##📂 / ##🙌 should include a space for consistent markdown rendering.

🧩 Suggested README cleanup
-Clone the repo:
-
-```bash
-git clone <your-repo-url>
-cd py-streamlit-translator
-Install dependencies:
-
-**Bash**
-
-pip install -r requirements.txt
-Run the app:
-
-**Bash**
-streamlit run app.py
+Clone the repo:
+
+```bash
+git clone https://github.com/lingodotdev/lingo.dev.git
+cd lingo.dev/community/py-streamlit-translator
+```
+
+Install dependencies:
+
+```bash
+pip install -r requirements.txt
+```
+
+Run the app:
+
+```bash
+streamlit run app.py
+```
@@
-##📂 Project Structure
+## 📂 Project Structure
@@
-##🙌 Contribution
+## 🙌 Contribution
📝 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
Clone the repo:
```bash
git clone <your-repo-url>
cd py-streamlit-translator
Install dependencies:
**Bash**
pip install -r requirements.txt
Run the app:
**Bash**
streamlit run app.py
## 💻 Usage:
Enter text
Select source language
Select target language
Click Translate
Get instant results 🎉
##📂 Project Structure
py-streamlit-translator/
│── app.py
│── requirements.txt
│── README.md
##🙌 Contribution
Clone the repo:
🤖 Prompt for AI Agents
In `@community/py-streamlit-translator/README.md` around lines 30 - 60, Update
README.md to fix unbalanced code fences and make the clone/install steps
repo-specific: replace the placeholder git clone with the monorepo URL and
correct subfolder path (use git clone
https://github.com/lingodotdev/lingo.dev.git then cd
lingo.dev/community/py-streamlit-translator), wrap the Clone, Install
dependencies, and Run the app commands each in proper ```bash fenced blocks, and
ensure headings like "## 📂 Project Structure" and "## 🙌 Contribution" include
a space after the emoji for consistent markdown rendering; locate these edits in
the README.md content for py-streamlit-translator.

Comment on lines +1 to +3
streamlit
lingodotdev
python-dotenv No newline at end of file
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find the app.py file and check its imports
fd -type f -name "app.py" | head -20

Repository: lingodotdev/lingo.dev

Length of output: 235


🏁 Script executed:

# Also check the directory structure to understand the project layout
git ls-files | grep -E "(requirements|setup|pyproject|app)" | head -30

Repository: lingodotdev/lingo.dev

Length of output: 775


🏁 Script executed:

cat -n "community/py-streamlit-translator/app.py"

Repository: lingodotdev/lingo.dev

Length of output: 1381


🏁 Script executed:

cat -n "community/py-streamlit-translator/requirements.txt"

Repository: lingodotdev/lingo.dev

Length of output: 121


🏁 Script executed:

# Check if there are any other dependency files in that directory
ls -la "community/py-streamlit-translator/"

Repository: lingodotdev/lingo.dev

Length of output: 357


Add missing deep-translator dependency.

app.py imports deep_translator.GoogleTranslator on line 2 and uses it on line 28, but the package is not listed in requirements.txt. This will cause a runtime ImportError when running the application.

🩹 Proposed update
 streamlit
 lingodotdev
 python-dotenv
+deep-translator
📝 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
streamlit
lingodotdev
python-dotenv
streamlit
lingodotdev
python-dotenv
deep-translator
🧰 Tools
🪛 OSV Scanner (2.3.2)

[HIGH] 1-1: protobuf 6.33.4: protobuf affected by a JSON recursion depth bypass

(GHSA-7gcm-g887-7qv7)

🤖 Prompt for AI Agents
In `@community/py-streamlit-translator/requirements.txt` around lines 1 - 3,
requirements.txt is missing the deep-translator package required by app.py (it
imports deep_translator.GoogleTranslator); add the dependency "deep-translator"
to requirements.txt so the import deep_translator.GoogleTranslator in app.py
resolves at runtime and prevents ImportError.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

GHSA-7gcm-g887-7qv7 protobuf vulnerability

💡 Result:

GHSA-7gcm-g887-7qv7 (CVE-2026-0994) is a DoS vulnerability in Python protobuf’s JSON parsing: google.protobuf.json_format.ParseDict() can bypass max_recursion_depth when parsing deeply nested google.protobuf.Any messages, eventually exhausting Python’s recursion stack (raising RecursionError) and crashing the process. Severity: High (CVSS 8.2). [1][2]

Affected: PyPI protobuf all versions <= 6.33.4. [1][2][3]

Fix status: As of the advisory publication (Jan 23, 2026), no patched version is listed; the upstream fix is being worked via PR protocolbuffers/protobuf#25239. [1][2][4]

Mitigations (until a release is available):

  • Avoid using json_format.ParseDict() / JSON-to-protobuf on untrusted JSON, especially when messages can include Any. [1][2]
  • If you must accept JSON: add your own input validation (cap nesting depth / reject or strictly whitelist Any usage) before calling protobuf JSON parsing. (Derived from the described root cause and attack.) [1][2]

Sources: [1] GitHub Advisory Database, [2] OSV entry, [3] PyPI release history showing 6.33.4, [4] upstream fix PR.


🏁 Script executed:

#!/bin/bash
# Check if we can determine streamlit's dependencies
# First, let's see what files are in the repository context
git ls-files community/py-streamlit-translator/ | head -20

Repository: lingodotdev/lingo.dev

Length of output: 200


🏁 Script executed:

#!/bin/bash
# Read the complete requirements.txt file
cat -n community/py-streamlit-translator/requirements.txt

Repository: lingodotdev/lingo.dev

Length of output: 121


🌐 Web query:

streamlit protobuf dependency version

💡 Result:

  • Latest Streamlit on PyPI: streamlit==1.53.1 (released Jan 22, 2026). [1]
  • Protobuf compatibility (by Streamlit version):
    • Streamlit 1.35.0 had the dependency constraint protobuf>=3.20,<5 (so protobuf 5.x would be rejected by pip). [2]
    • Streamlit later added support for protobuf v5, so newer Streamlit versions are intended to work with protobuf 5.x. [3]

If you’re trying to resolve an environment conflict, the key takeaway is: protobuf 5.x requires a Streamlit version new enough to support protobuf 5; older Streamlit versions (e.g., 1.35.0) will force protobuf <5. [2][3]

Sources: [1] [2] [3]


🌐 Web query:

streamlit 1.53.1 requirements protobuf version constraint

💡 Result:

For Streamlit 1.53.1, the protobuf dependency constraint is:

  • protobuf >= 3.20, < 5 (i.e., protobuf 5.x is not allowed). [1][2]

Sources: Streamlit dependency conflict reports explicitly show streamlit … depends on protobuf<5 and >=3.20. [1][2]


Audit transitive protobuf vulnerability in Streamlit dependency.

Streamlit requires protobuf >= 3.20, < 5, which falls within the vulnerable range for GHSA-7gcm-g887-7qv7 (HIGH severity DoS in JSON parsing). This vulnerability affects all protobuf versions ≤ 6.33.4, and no patched version is currently available (upstream fix is in progress as of January 2026).

Until a patched release is available:

  • Avoid using google.protobuf.json_format.ParseDict() on untrusted JSON input, especially with messages containing google.protobuf.Any fields.
  • If JSON parsing is necessary, implement input validation to cap nesting depth and restrict or reject Any usage before calling protobuf JSON parsing functions.

Monitor the upstream fix (protocolbuffers/protobuf#25239) for a patched release and upgrade when available.

🧰 Tools
🪛 OSV Scanner (2.3.2)

[HIGH] 1-1: protobuf 6.33.4: protobuf affected by a JSON recursion depth bypass

(GHSA-7gcm-g887-7qv7)

🤖 Prompt for AI Agents
In `@community/py-streamlit-translator/requirements.txt` around lines 1 - 3, The
Streamlit dependency in requirements.txt pulls a protobuf version in the
vulnerable range; to mitigate, locate any codepaths that parse protobuf JSON
(search for usages of google.protobuf.json_format.ParseDict, Parse,
MessageToJson, or any code handling google.protobuf.Any) and replace direct
ParseDict calls with a safe wrapper that first validates input: enforce a
maximum JSON nesting depth, reject or strip Any fields, and disallow untrusted
JSON before calling protobuf parsers; add defensive checks where streamlit-based
components accept user JSON input and document/monitor
protocolbuffers/protobuf#25239 to upgrade protobuf to a patched release as soon
as it is published.

@laibaishfaq108-blip
Copy link
Author

Hi, I've completed the updates and pushed the changes
.This was my first contribution .Please review when you get time.
Thank you!

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