FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix GE path check for unprefixed paths by carl-codeorg · Pull Request #74813 · code-dot-org/code-dot-org · GitHub

fix GE path check for unprefixed paths - #74813

Merged
carl-codeorg merged 3 commits into
stagingfrom
p20-1957/ge-cap-routing
Aug 24, 2026
Merged

fix GE path check for unprefixed paths#74813
carl-codeorg merged 3 commits into
stagingfrom
p20-1957/ge-cap-routing

Conversation

carl-codeorg commented Aug 21, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

CAP parent permission requests are currently broken in Global Edition. What appears to be happening is:

  • The button to send a parental permission request on the lockout page posts directly to '/policy_compliance/child_account_consent'
  • GE makes it so the route helpers include the language slug
  • handle_cap_lockout checks using the route helpers, and doesn't find a match because request.path has no language slug, e.g. '/policy_compliance/child_account_consent' does not match '/la/policy_compliance/child_account_consent'. The permission request controller action is never invoked.
  • User is redirected to the lockout page, with Accept: application/json from the original request, which returns a 406. The user then sees a generic server-side error message, and no parental permission request is ever sent.

Links

  • Jira:

Testing story

Deployment notes

Privacy and security

# URLs we should not redirect. Global Edition prefixes generated paths with
# the active region, even when the incoming API request is unprefixed.
# Compare the underlying paths so both forms match.
request_path = Cdo::GlobalEdition.match_path(request.path).try(:[], :main_path) || request.path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This totally makes sense. The only thing I would consider is extracting the repeated path normalization into something like Cdo::GlobalEdition.unprefixed_path, since the same logic is already used in several places:

path = match_path(path)&.try(:[], :main_path) || path

module Cdo::GlobalEdition
  def self.unprefixed_path(path)
    match_path(path).try(:[], :main_path) || path
  end
end
Suggested change
request_path = Cdo::GlobalEdition.match_path(request.path).try(:[], :main_path) || request.path
request_path = Cdo::GlobalEdition.unprefixed_path(request.path)

Copy link
Copy Markdown
Member

Another thing is that most of the Studio (Dashboard) path/url helper methods are now also available on the frontend, with all the Global Edition routing logic handled by them:

import {policy_compliance_pending_permission_request_path} from '@cdo/generated-scripts/studioRoutes';

].any? {|path| request.path.include?(path)}
].any? do |path|
path = Cdo::GlobalEdition.match_path(path).try(:[], :main_path) || path
request_path.include?(path)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not sure we should change this as part of this fix, but I think it would make more sense to check whether the request path starts with one of the excluded paths instead of checking for a match anywhere in the path:

Suggested change
request_path.include?(path)
request_path.start_with?(path)

carl-codeorg marked this pull request as ready for review August 24, 2026 22:48
carl-codeorg requested a review from a team August 24, 2026 22:48
carl-codeorg merged commit e4b403e into staging Aug 24, 2026
7 checks passed
carl-codeorg deleted the p20-1957/ge-cap-routing branch August 24, 2026 23:25
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL