Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions src/frame/middleware/render-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { get } from 'lodash-es'

import getMiniTocItems from '@/frame/lib/get-mini-toc-items'
import patterns from '@/frame/lib/patterns'
import { pathLanguagePrefixed } from '@/languages/lib/languages'
import FailBot from '@/observability/lib/failbot'
import statsd from '@/observability/lib/statsd'
import type { ExtendedRequest } from '@/types'
Expand All @@ -16,7 +15,6 @@ import { isConnectionDropped } from './halt-on-dropped-connection'
import { nextHandleRequest } from './next'

const STATSD_KEY_RENDER = 'middleware.render_page'
const STATSD_KEY_404 = 'middleware.render_404'

async function buildRenderedPage(req: ExtendedRequest): Promise<string> {
const { context } = req
Expand Down Expand Up @@ -69,33 +67,10 @@ export default async function renderPage(req: ExtendedRequest, res: Response) {
)
}

if (!pathLanguagePrefixed(req.path)) {
defaultCacheControl(res)
return res.status(404).type('html').send(minimumNotFoundHtml)
}

// For App Router migration: All language-prefixed 404s should use App Router
statsd.increment(STATSD_KEY_404, 1, [
`url:${req.url}`,
`path:${req.path}`,
`referer:${req.headers.referer || ''}`,
])

// send minimal 404 at this point since we ran into hydration issues trying to pass
// these along to AppRouter 404 handling
defaultCacheControl(res)

// Create a mock request that will be handled by App Router
const mockReq = Object.create(req)
mockReq.url = '/404'
mockReq.path = '/404'
mockReq.method = 'GET'

// Only pass pathname
res.setHeader('x-pathname', req.path)

// Import nextApp and handle directly
const { nextApp } = await import('./next')
res.status(404)
return nextApp.getRequestHandler()(mockReq, res)
return res.status(404).type('html').send(minimumNotFoundHtml)
}

// Just finish fast without all the details like Content-Length
Expand Down
5 changes: 5 additions & 0 deletions src/frame/tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ describe('server', () => {
expect($.res.statusCode).toBe(404)
})

test('renders a 404 for language prefixed versioned non-existent pages', async () => {
const res = await get('/en/enterprise-cloud@latest/nonexistent-page')
expect(res.statusCode).toBe(404)
})

// When using `got()` to send full end-to-end URLs, you can't use
// URLs like in this test because got will
// throw `RequestError: URI malformed`.
Expand Down
14 changes: 14 additions & 0 deletions src/graphql/data/fpt/changelog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
[
{
"schemaChanges": [
{
"title": "The GraphQL schema includes these changes:",
"changes": [
"<p>Field <code>viewerCanSetFields</code> was added to object type <code>Issue</code></p>",
"<p>Field <code>viewerCanSeeIssueFields</code> was added to object type <code>Repository</code></p>"
]
}
],
"previewChanges": [],
"upcomingChanges": [],
"date": "2025-08-26"
},
{
"schemaChanges": [
{
Expand Down
10 changes: 10 additions & 0 deletions src/graphql/data/fpt/schema.docs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19546,6 +19546,11 @@ type Issue implements Assignable & Closable & Comment & Deletable & Labelable &
"""
viewerCanReopen: Boolean!

"""
Check if the current viewer can set fields on the issue.
"""
viewerCanSetFields: Boolean

"""
Check if the viewer is able to change their subscription status for the repository.
"""
Expand Down Expand Up @@ -51312,6 +51317,11 @@ type Repository implements Node & PackageOwner & ProjectOwner & ProjectV2Recent
reason: "Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC."
)

"""
Indicates whether the current user can see issue fields in this repository
"""
viewerCanSeeIssueFields: Boolean!

"""
Check if the viewer is able to change their subscription status for the repository.
"""
Expand Down
16 changes: 16 additions & 0 deletions src/graphql/data/fpt/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30735,6 +30735,14 @@
"kind": "scalars",
"href": "/graphql/reference/scalars#boolean"
},
{
"name": "viewerCanSetFields",
"description": "<p>Check if the current viewer can set fields on the issue.</p>",
"type": "Boolean",
"id": "boolean",
"kind": "scalars",
"href": "/graphql/reference/scalars#boolean"
},
{
"name": "viewerCanSubscribe",
"description": "<p>Check if the viewer is able to change their subscription status for the repository.</p>",
Expand Down Expand Up @@ -67952,6 +67960,14 @@
"isDeprecated": true,
"deprecationReason": "<p>Projects (classic) is being deprecated in favor of the new Projects experience, see: <a href=\"https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/\">https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/</a>. Removal on 2025-04-01 UTC.</p>"
},
{
"name": "viewerCanSeeIssueFields",
"description": "<p>Indicates whether the current user can see issue fields in this repository.</p>",
"type": "Boolean!",
"id": "boolean",
"kind": "scalars",
"href": "/graphql/reference/scalars#boolean"
},
{
"name": "viewerCanSubscribe",
"description": "<p>Check if the viewer is able to change their subscription status for the repository.</p>",
Expand Down
10 changes: 10 additions & 0 deletions src/graphql/data/ghec/schema.docs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19546,6 +19546,11 @@ type Issue implements Assignable & Closable & Comment & Deletable & Labelable &
"""
viewerCanReopen: Boolean!

"""
Check if the current viewer can set fields on the issue.
"""
viewerCanSetFields: Boolean

"""
Check if the viewer is able to change their subscription status for the repository.
"""
Expand Down Expand Up @@ -51312,6 +51317,11 @@ type Repository implements Node & PackageOwner & ProjectOwner & ProjectV2Recent
reason: "Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC."
)

"""
Indicates whether the current user can see issue fields in this repository
"""
viewerCanSeeIssueFields: Boolean!

"""
Check if the viewer is able to change their subscription status for the repository.
"""
Expand Down
16 changes: 16 additions & 0 deletions src/graphql/data/ghec/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30735,6 +30735,14 @@
"kind": "scalars",
"href": "/graphql/reference/scalars#boolean"
},
{
"name": "viewerCanSetFields",
"description": "<p>Check if the current viewer can set fields on the issue.</p>",
"type": "Boolean",
"id": "boolean",
"kind": "scalars",
"href": "/graphql/reference/scalars#boolean"
},
{
"name": "viewerCanSubscribe",
"description": "<p>Check if the viewer is able to change their subscription status for the repository.</p>",
Expand Down Expand Up @@ -67952,6 +67960,14 @@
"isDeprecated": true,
"deprecationReason": "<p>Projects (classic) is being deprecated in favor of the new Projects experience, see: <a href=\"https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/\">https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/</a>. Removal on 2025-04-01 UTC.</p>"
},
{
"name": "viewerCanSeeIssueFields",
"description": "<p>Indicates whether the current user can see issue fields in this repository.</p>",
"type": "Boolean!",
"id": "boolean",
"kind": "scalars",
"href": "/graphql/reference/scalars#boolean"
},
{
"name": "viewerCanSubscribe",
"description": "<p>Check if the viewer is able to change their subscription status for the repository.</p>",
Expand Down
4 changes: 2 additions & 2 deletions src/secret-scanning/data/public-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5558,7 +5558,7 @@
isPublic: true
isPrivateWithGhas: true
hasPushProtection: true
hasValidityCheck: '{% ifversion fpt or ghes %}false{% else %}true{% endif %}'
hasValidityCheck: false
base64Supported: false
isduplicate: true
- provider: WorkOS
Expand All @@ -5571,7 +5571,7 @@
isPublic: true
isPrivateWithGhas: true
hasPushProtection: true
hasValidityCheck: '{% ifversion fpt or ghes %}false{% else %}true{% endif %}'
hasValidityCheck: false
base64Supported: false
isduplicate: true
- provider: xAI
Expand Down
4 changes: 2 additions & 2 deletions src/secret-scanning/lib/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sha": "428b03b8d51ba2b06dcd11b03a5548e627c64faf",
"blob-sha": "7acf4c4d90e79612ebf5f405772e3678a1757711",
"sha": "44a6c7a210c90e7d599674b70e8835b5292b4215",
"blob-sha": "c74f02d913adea5b78986158480cb9533e41bafe",
"targetFilename": "code-security/secret-scanning/introduction/supported-secret-scanning-patterns"
}
Loading