Conversation
05506ce to
f438ad6
Compare
Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
f438ad6 to
27070e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Summary
This PR contains two fixes:
1. Whitespace
team_idvisibility coercionAll 6 edit functions in the Admin UI (
editTool,editGateway,editA2AAgent,editResource,editPrompt,editServer) were checking rawteamIdtruthiness to decide whether to coerce apublicvisibility record toteam. A whitespace-only URL parameter (?team_id=%20) is truthy in JS, causing silent coercion whileisTeamScopedView()— already trim-aware — correctly returnedfalse. The Python server-side guard had the same gap. This fix makes all checks consistent.2. Dead code removal in
servers.jsserverDesc.textContentwas assigned viadecodeHtml()and then immediately overwritten with the raw value on the next line, making thedecodeHtmlcall unreachable and causing HTML entities in server descriptions to render incorrectly.🔗 Related Issue
Closes: #3338
🔁 Reproduction Steps
ALLOW_PUBLIC_VISIBILITY=false.?team_id=%20in the URL.publicvisibility.isTeamScopedView()returnsfalse), but the visibility is silently coerced toteamon submit.🐞 Root Cause
The
effectiveVisibilityternary in each of the 6 edit functions used the raw URL-derivedteamId/_teamIdvariable directly:" "(whitespace) is truthy, so it triggered coercion. MeanwhileisTeamScopedView()inteams.jscorrectly trims before checking, returningfalsefor whitespace-only values. The two code paths were inconsistent.On the Python side,
_check_public_visibility_allowedinadmin.pyhad the same raw-truthiness check (and team_id).💡 Fix Description
Fix 1 — Whitespace
team_idcoercionisTeamScopedViewto the import from./teams.jsin each affected module and replaced the rawteamId/_teamIdcondition in theeffectiveVisibilityternary withisTeamScopedView(). ForeditResource,editPrompt, andeditServer, the now-redundant local_teamIdvariable was also removed.admin.py): Changedand team_id→and team_id and team_id.strip()in_check_public_visibility_allowedso both layers treat whitespace-only values as absent.Fix 2 — Dead code removal (
servers.js)serverDesc.textContent = server.descriptionline that immediately overwrote thedecodeHtml()result, so HTML entities in server descriptions are now decoded correctly.prompts.test.jsto includesearchin the mockedwindow.location(required sinceisTeamScopedViewreadslocation.search, nothref). Added a whitespace-onlyteam_idtest asserting no coercion occurs. Updated theteams.jsmock inresources.test.jsto exportisTeamScopedView(previously missing, would throw at runtime in tests). Added 3 direct tests of_check_public_visibility_allowedintest_admin.pycovering spaces-only, tab, and a realteam_idto verify theteam_id.strip()branch.🧪 Verification
make lintmake testmake coverage?team_id=%20, open any edit modal with a public entity — coercion no longer occurs📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)