Repository navigation
Conversation
…d count only what visitors can open - REST GET article/category reads: a key without help_center.manage (or a scoped key without its scope) reads only the published public help center. A draft, private or gated article or category answers 403; the lists fall back to the public slice. - listPublicCategories counts articles the viewer can open, rolled up only through subcategories the viewer can open. - A signed-out visitor who changes their vote replaces it instead of adding a second one: the page sends back the vote id it was handed, and the service flips that row only when it is a signed-out vote on the same article.
This branch has not been deployed
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.
Fixes three help center access bugs that the product e2e suite found. The owner should review the access decisions listed below.
Fixed quarantined e2e journeys
help_center.managecould read drafts and private categories over REST.These specs are on #1159 and #1174, which are still open. I have not run them locally against this branch. Unit, component and DB tests cover each fix.
Changes
REST reads (HC-B3)
apiKeyHolds(auth, permission)indomains/api/auth.ts. It checks the permission and the scope that permission maps to, using the same rules as the write gates, but returns a boolean.GET /help-center/articles: a key without manage getslistPublicArticles, which returns published articles in public categories that no segment gate hides.statusis ignored for these keys.GET /help-center/articles/{id}andGET /help-center/categories/{id}: a draft, a private or gated article, or a private or gated category answers 403 for a key without manage. An id that does not exist still answers 404.GET /help-center/categories: a key without manage getslistPublicCategories, with counts that include only articles everyone can open.Landing card counts (HC-B14)
listPublicCategorieshas moved tohelp-center.public-category.query.ts. The category service re-exports it, so callers are unchanged. It counts only articles that passhelpCenterVisibilityConditions('public', viewer), and adds up subcategories the viewer can open. A subcategory the viewer cannot open adds nothing to its parent, and neither does anything below it. This matches what the category page links to.Signed-out votes (HC-B2)
recordArticleFeedback(articleId, helpful, principalId, { replaces }): a signed-out vote can now replace an earlier vote, found by the id the page was given. It only replaces a signed-out vote on the same article, so a vote id cannot reach a signed-in visitor's vote or a vote on another article. The flip is guarded in the UPDATE's WHERE clause, and the counters change only when a row actually flipped.articleFeedbackSchemahas a new optionalreplacesFeedbackId, validated as akb_article_feedbackTypeID. The portal feedback component sends it after the first vote.Decisions for the owner
write:articlenow gets only the public content, even an admin'sread:articlekey. Its lists shrink quietly instead of answering 403.Tests (RED on origin/main, GREEN here)
routes/api/v1/help-center/__tests__/read-access.test.ts: on origin/main, all 8 checks of what a contributor key and a read-scoped owner key may read failed. 5 checks confirm that manager keys and public reads still work.domains/help-center/__tests__/help-center-public-access.db.test.tsruns against a real DB using the transactional fixture. On origin/main the card count was 9 where 2 is right, an all-hidden parent was listed, and both vote-flip tests failed. A guard test checks that a signed-in vote and a vote on another article are never rewritten.components/help-center/__tests__/help-center-article-feedback.test.tsx: on origin/main, the second vote did not send the earlier vote id.lib/shared/schemas/__tests__/article-feedback-schema.test.tschecks which vote ids the schema accepts and refuses.apiKeyHolds, and the mockedlistPublicCategoriestests match the new count query.oxlint, prettier and the web typecheck are clean. All tests in the help-center domain, the REST routes, the API domain and the help-center components pass.
Notes
quackback://help-center/categoriesresource (lib/server/mcp/server.tsaround line 195) checks only for a team role, so it lists private categories to any teammate. MCP search and get already requirehelp_center.manage. This PR leaves the resource unchanged.fix/help-center-authoringboth editroutes/api/v1/help-center/{articles/$articleId,categories/$categoryId}.ts,lib/shared/schemas/help-center.tsandlib/server/functions/help-center.ts, in different hunks. Whichever merges second needs a rebase.fix/rest-input-errorsalso edits these routes.