Skip to content

Check channel permissions in language_exists and languages actions - #6428

Open
adibmbrk wants to merge 2 commits into
learningequality:hotfixesfrom
adibmbrk:fix-channel-language-actions-permission
Open

adibmbrk wants to merge 2 commits into
learningequality:hotfixesfrom
adibmbrk:fix-channel-language-actions-permission

Conversation

@adibmbrk

@adibmbrk adibmbrk commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The channel language_exists and languages actions queried Channel.objects directly, so any logged-in user could read a private channel's content languages by id, and tell whether the id exists.

Both actions now load the channel with get_object(), like the other detail actions. A user who can't view the channel gets the same 404 as GET /api/channel/<id> or a nonexistent id. Editors and viewers get the same responses as before. The now-unused _channel_exists and _get_channel_details helpers are removed.

References

Fixes #6399

Reviewer guidance

  • Ran ChannelLanguageTestCase in test_channel.py; all 11 tests pass. I did not run the rest of the suite.
  • New regression tests cover a non-member, a viewer, and a nonexistent id on both actions. The existing tests now authenticate as a channel editor, since a random user no longer has access.
  • Not manually tested against a running server.

AI usage

I used Claude Code to read the issue, make the change in channel.py, and write the regression tests, following the get_object() pattern used by the other detail actions. I ran the language tests to confirm they pass.

Load the channel through get_object() so users who can't view it get the same 404 as a nonexistent channel.

Signed-off-by: adibmbrk <adibmbrk@gmail.com>
@adibmbrk
adibmbrk requested review from a team and leq-bot November 17, 2026 16:10
@learning-equality-bot

Copy link
Copy Markdown
Contributor

👋 Hi @adibmbrk, thanks for contributing!

For the review process to begin, please verify that the following is satisfied:

  • Contribution is aligned with our contributing guidelines

  • Pull request description has correctly filled AI usage section & follows our AI guidance:

    AI guidance

    State explicitly whether you didn't use or used AI & how.

    If you used it, ensure that the PR is aligned with Using AI as well as our DEEP framework. DEEP asks you:

    • Disclose — Be open about when you've used AI for support.
    • Engage critically — Question what is generated. Review code for correctness and unnecessary complexity.
    • Edit — Review and refine AI output. Remove unnecessary code and verify it still works after your edits.
    • Process sharing — Explain how you used the AI so others can learn.

    Examples of good disclosures:

    "I used Claude Code to implement the component, prompting it to follow the pattern in ComponentX. I reviewed the generated code, removed unnecessary error handling, and verified the tests pass."

    "I brainstormed the approach with Gemini, then had it write failing tests for the feature. After reviewing the tests, I used Claude Code to generate the implementation. I refactored the output to reduce verbosity and ran the full test suite."

📢✨ Before we assign a reviewer:

  • @rtibblesbot will pre-review this pull request. Its comments are generated by an LLM, and should be evaluated accordingly.
  • We'll also invite community pre-review. See the community review guidance for both authors and reviewers.

Also check that issue requirements are satisfied & you ran pre-commit locally.

Pull requests that don't follow the guidelines will be closed.

Reviewer assignment can take up to 2 weeks.

📎 We couldn't find an issue linked to this pull request. Please edit the description and link one under References, for example Fixes #123 or Closes #123. A plain #123 mention doesn't link the PR to the issue.

@rtibbles
rtibbles requested a review from rtibblesbot November 18, 2026 17:16
@learning-equality-bot

Copy link
Copy Markdown
Contributor

📢✨ Before we assign a reviewer, we'll turn on @rtibblesbot to pre-review. Its comments are generated by an LLM, and should be evaluated accordingly.

rtibblesbot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Waiting for changes

Outcome: reviewed 4a71345

Last updated: 2026-11-24 08:17 UTC

@rtibblesbot rtibblesbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR #6428: Switching both actions to get_object() closes the leak and gives denied and missing channels the same 404.

CI failing: lint.

  • blocking — contentcuration/contentcuration/viewsets/channel.py:4: from typing import Dict is now unused. flake8 reports it as F401, which fails the lint job. Delete the import.
  • suggestion — get_object() loads more than these actions need (inline).
  • nitpick — one redundant test (inline).

Next step: Needs a full code review by a human engineer.

  • The author is outside the team: confirm this should be built at all.

Written by rtibblesbot, an LLM-based coding agent.

Signed-off-by: adibmbrk <adibmbrk@gmail.com>

@rtibblesbot rtibblesbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR #6428: both prior findings are resolved. No new findings. CI is still running.

Prior-finding status

RESOLVED — contentcuration/contentcuration/viewsets/channel.py — get_object() loads far more than these actions need
RESOLVED — contentcuration/contentcuration/tests/viewsets/test_channel.py — non-member test duplicates test_language_actions_nonexistent_channel_matches_non_member

Next step: Needs a full code review by a human engineer.

  • The author is outside the team.
  • Confirm 404 for non-members on language_exists/languages is the intended permission behaviour for these channel endpoints.

Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot
rtibblesbot dismissed their stale review November 24, 2026 08:17

Superseded by my review of 4a71345: no blocking findings remain.

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.

Channel language_exists and languages actions skip the channel permission check

2 participants