okTurtles / okTurtles/forkana

Profile and org pages can still offer to create a subject that already exists

Open
#369 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3
Forks
0
Avg merge
5d 20h
Merged PRs (30d)
32

Description

Split out of #319, which fixed this on the Explore Subjects page only.

Problem

custom/templates/shared/repo/list.tmpl renders an empty state that offers to create a subject:

{{ctx.Locale.Tr "search.search_results_for" $.Keyword}}
{{ctx.Locale.Tr "search.no_exact_page_found" $.Keyword}}
<a href="{{AppSubUrl}}/repo/create?subject={{QueryEscape $.Keyword}}">Create new subject</a>

Taking that offer routes through GetOrCreateSubject, which returns the existing subject and attaches the new article to it as a fork — the duplicate-invite described in #319.

#319 guards the equivalent affordance on /explore/subjects with an unfiltered existence probe (ExactSubjectExists, from GetSubjectBySlug). That guard does not reach this template.

Why it is not covered

After PR #368 removes /explore/articles, explore.RenderRepoSearch has exactly one caller, routers/web/admin/repos.go:33 — and templates/admin/repo/list.tmpl includes shared/repo/search but not shared/repo/list (it renders a <table> instead).

The five templates that do include shared/repo/list are served by handlers that never call RenderRepoSearch, so ExactSubjectExists is never set for them:

  • templates/org/home.tmpl
  • templates/user/profile.tmpl
  • templates/user/notification/notification_subscriptions.tmpl
  • templates/admin/user/view.tmpl
  • templates/repo/forks.tmpl

So on a user profile or org home, searching for a name that matches an existing subject whose articles are not listed on that page still shows "Create new subject".

Suggested fix

Either wire the same existence probe into the handlers behind those pages, or — probably better — reconsider whether a repo-list empty state on a profile should be offering subject creation at all. On a profile the honest empty state is "this user has no matching articles", not an invitation to create a subject.

Notes

Found while reworking #361 after /explore/articles was removed. Not folded into #319 because the fix is materially larger than that issue's scope and touches unrelated handlers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with custom/templates/shared/repo/list.tmpl and trace the five callers listed: templates/org/home.tmpl, templates/user/profile.tmpl, templates/user/notification/notification_subscriptions.tmpl, templates/admin/user/view.tmpl, and templates/repo/forks.tmpl. Compare them with explore.RenderRepoSearch and routers/web/admin/repos.go:33, including the ExactSubjectExists probe. Done means those pages no longer offer an invalid subject-creation action, using one of the issue's proposed approaches.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.