Skip to content

feat(addon): set category in component discovery - #23004

Open
gersona wants to merge 8 commits into
WeblateOrg:mainfrom
gersona:14441_component_discovery
Open

gersona wants to merge 8 commits into
WeblateOrg:mainfrom
gersona:14441_component_discovery

Conversation

@gersona

@gersona gersona commented Nov 20, 2026

Copy link
Copy Markdown
Member

@gersona
gersona marked this pull request as ready for review November 24, 2026 17:46
@gersona
gersona requested a review from nijel as a code owner November 24, 2026 17:46

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread weblate/trans/discovery.py Resolved
Comment thread weblate/trans/discovery.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 258 files (changes from recent commits).

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.

Re-trigger cubic

Comment thread weblate/checks/markup.py Resolved
Comment thread weblate/glossary/models.py Resolved
Comment thread weblate/locale/cs/LC_MESSAGES/django.po Resolved
Comment thread docs/locales/hr/LC_MESSAGES/docs.po Resolved
Comment thread weblate/api/routers.py Resolved
Comment thread docs/locales/it/LC_MESSAGES/docs.po Resolved
Comment thread docs/changes.rst Resolved
Comment thread docs/locales/nl/LC_MESSAGES/docs.po Resolved
Comment thread weblate/locale/es/LC_MESSAGES/django.po Resolved
@gersona
gersona force-pushed the 14441_component_discovery branch from ecc28c0 to 75ff6e1 Compare November 28, 2026 11:41
@nijel

nijel commented Nov 29, 2026

Copy link
Copy Markdown
Member

@codex review

@nijel nijel self-assigned this Nov 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T07:47:59.005898Z 75ff6e1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75ff6e17dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1599 to +1601
identifier_cache.clear()
identifier_cache.update(identifier_snapshot)
self._category_chain_cache = chain_snapshot

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove created category directories when a match rolls back

When a match creates a new multi-level category path and then fails component validation, for example because a translation file cannot be parsed, the transaction rolls back the category rows but not the directories created by Category.save() through PathMixin.create_path(). The orphaned parent directory contains its child directories, so subsequent matches and retries fail Category.validate_create_path() with “Repository path for this category already exists and is not empty,” even after the invalid file is fixed. Track and clean up directories introduced by the failed match, or defer their creation, alongside restoring these caches.

Useful? React with 👍 / 👎.

project=project,
category=parent,
)
category.full_clean()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate inherited category licenses using their effective values

With LICENSE_REQUIRED=True at startup, each missing category reaches this call with the model default license="". Category.license has blank=False under that setting, and Category lacks the inheritance-aware clean_fields() override used by Component, so full_clean() rejects the empty stored override even when the parent supplies a valid inherited license. Consequently, discovery skips every match that needs a missing category on these installations. Exclude inherited overrides from field validation or validate their effective values.

Useful? React with 👍 / 👎.

Comment on lines +1457 to +1459
level_slugs, level_names = identifier_cache[parent_id]
level_slugs.add(category.slug.lower())
level_names.add(category.name.lower())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check queued component reservations before creating categories

With asynchronous discovery, a layout containing guides/install.md and guides/install/intro.md can queue the install component before processing the nested file. If the worker has not inserted that component yet, category validation sees no database conflict and creates the install category despite that slug already being reserved in identifier_cache. The queued component subsequently fails create_component()'s uniqueness validation against the new category and is never created in that run. Account for queued component reservations before saving categories, rather than only adding category identifiers to the cache afterward.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

Component Discovery: set the category

2 participants