asf-tooling commented on issue #1228:
URL: 
https://github.com/apache/tooling-trusted-releases/issues/1228#issuecomment-4407467623

   <!-- gofannon-issue-triage-bot v2 -->
   
   **Automated triage** — analyzed at `main@751c2146`
   
   **Type:** `bug_fix`  •  **Classification:** `actionable`  •  **Confidence:** 
`medium`
   **Application domain(s):** `voting`, `announcements_reporting`
   
   ### Summary
   The `short_display_name` property on the `Project` model (in 
`atr/models/sql.py`) incorrectly handles project names that begin with 'Apache' 
but where that word is integral to the name (e.g., 'Apache Software Foundation 
Parent POM'). The property likely strips the 'Apache ' prefix, resulting in 
'Software Foundation Parent POM' on the vote page heading and in the 
`{{PROJECT}}` template variable used for vote subjects. @sbp acknowledged the 
issue, attempted a fix in commit 837830e8, but stated 'The code as it is is 
still wrong, but it's wrong in a new way!' — so a better solution is still 
needed.
   
   ### Where this lives in the code today
   
   #### `atr/construct.py` — `_podling_disclaimer` (lines 294-302)
   _currently does this_
   This function prepends 'Apache ' to `project.name`, showing that `name` is 
expected to NOT have an 'Apache' prefix for typical projects — but edge-case 
names like 'Apache Software Foundation Parent POM' would produce 'Apache Apache 
Software Foundation Parent POM'.
   
   ```python
   def _podling_disclaimer(project: sql.Project, committee: sql.Committee) -> 
str:
       if not committee.is_podling:
           return ""
       project_name = project.name or str(project.key)
       return (
           f"\nDISCLAIMER: Apache {project_name} is an effort undergoing "
           "incubation at The Apache Software Foundation (ASF), sponsored "
           ...
       )
   ```
   
   ### Where new code would go
   - `atr/models/sql.py` — Project.short_display_name property
     The `short_display_name` property on the `Project` model is where the 
'Apache' prefix logic lives and where the fix needs to be applied.
   
   ### Proposed approach
   The fix belongs in the `short_display_name` property on the `Project` model 
in `atr/models/sql.py`. The property currently appears to unconditionally 
prepend 'Apache ' to the project name (or strip and re-add it). For projects 
whose name already starts with 'Apache ' as an integral part of the name (like 
'Apache Software Foundation Parent POM'), this logic produces incorrect results.
   
   A robust solution would be: if `project.name` already starts with 'Apache ', 
return it unchanged. Otherwise prepend 'Apache '. This handles both typical 
cases ('Maven' → 'Apache Maven') and edge cases ('Apache Software Foundation 
Parent POM' → 'Apache Software Foundation Parent POM'). Note that 
`_podling_disclaimer` in `construct.py` has the same issue — it unconditionally 
prepends 'Apache ' to `project.name`, which would produce 'Apache Apache 
Software Foundation Parent POM' for podling projects with this naming pattern. 
Since @sbp noted the code is 'still wrong in a new way' after commit 837830e8, 
the actual current state may differ from my inference, so the exact property 
implementation should be verified before applying any fix.
   
   ### Open questions
   - What is the current implementation of `short_display_name` in 
`atr/models/sql.py` after commit 837830e8? Without seeing it, the exact fix 
cannot be proposed.
   - How should `_podling_disclaimer` in `construct.py` handle names that 
already start with 'Apache'? It currently does `f'Apache {project_name}'` which 
would double the prefix.
   - Is there a separate `display_name` property and how does it relate to 
`short_display_name`? The vote page uses both differently.
   - What is the 'new way' in which @sbp said the code is wrong after the 
initial fix? This would inform the correct approach.
   - Should there be a database-level field to store the canonical short 
display name rather than computing it with heuristics?
   
   ### Files examined
   - `atr/construct.py`
   - `atr/get/voting.py`
   - `atr/post/voting.py`
   - `atr/shared/voting.py`
   - `tests/unit/test_construct_announce.py`
   - `atr/get/vote.py`
   - `atr/tasks/vote.py`
   - `atr/storage/writers/announce.py`
   
   ---
   *Draft from a triage agent. A human reviewer should validate before merging 
any change. The agent did not run tests or verify diffs apply.*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to