Fix some aspects of endpoint by whisper67265 · Pull Request #105 · cppalliance/cppa-weblate-plugin · GitHub
Skip to content

Fix some aspects of endpoint#105

Merged
wpak-ai merged 8 commits into
cppalliance:developfrom
whisper67265:fix/endpoint
Jun 10, 2026
Merged

Fix some aspects of endpoint#105
wpak-ai merged 8 commits into
cppalliance:developfrom
whisper67265:fix/endpoint

Conversation

@whisper67265

@whisper67265 whisper67265 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Close #99, close #103, close #102.

Summary by CodeRabbit

  • New Features

    • Structured error reporting with stable machine-readable codes and metadata; validation now returns structured per-field error payloads in HTTP 400 responses.
  • Bug Fixes

    • Improved error handling and recovery for git operations and component processing to avoid data loss on failures.
    • Background task errors now carry typed codes for clearer monitoring and predictable failure semantics.
  • Tests

    • Expanded coverage for structured errors, serializer behavior, services, tasks, and error-wrapping.
  • Documentation

    • API docs updated to describe the unified structured error format and error-code table.
  • Chores

    • Example configuration default changed to open registrations.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

@whisper67265 whisper67265 changed the title Fix/endpoint Fix some aspects of endpoint Jun 9, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.env.example:
- Line 50: There is a duplicate environment variable definition for
WEBLATE_REGISTRATION_OPEN; remove the redundant entry so the variable is defined
only once (keep the intended value and delete the other line), ensuring the
single remaining WEBLATE_REGISTRATION_OPEN entry reflects the correct
boolean/value used by the application.

In `@src/boost_weblate/endpoint/serializers.py`:
- Around line 87-115: The _flatten_field_errors function in
AddOrUpdateRequestSerializer currently stringifies DRF ErrorDetail objects which
breaks stable error-code mapping; modify _flatten_field_errors to propagate each
error's drf_code (use getattr(err, "code", None)) and return tuples like
(subfield, message, drf_code) instead of just (subfield, message), update any
call sites (including _code_for_drf_error) to accept the new triplet shape, and
change _code_for_drf_error to map DRF codes directly (e.g., ListField codes
"not_a_list" and "empty" → INVALID_SUBMODULE_LIST, missing field "required" →
REQUIRED_FIELD) rather than doing substring matching on message text. Ensure
nested branches (lists, dicts, ErrorDetail instances) preserve and propagate the
drf_code and adjust tests/consumers to handle the new tuple form.

In `@src/boost_weblate/endpoint/services.py`:
- Around line 131-138: The code currently runs subprocess.run(...) and uses
git_status.stdout without checking git_status.returncode, so add an explicit
check after the subprocess call (inspect git_status.returncode) and treat any
non-zero return code as a failure: log the error including git_status.stderr and
git_status.returncode (using the existing logger), and abort/raise (do not
proceed with DB deletion) when returncode != 0; update the block around the
subprocess.run invocation and the git_status variable usage to enforce this
explicit failure path (reference: git_status, subprocess.run call that uses
["git", "-C", base_path, "status", "--porcelain"]).
- Around line 146-156: The git commit call in subprocess.run (the one building
args with "git", "-C", base_path, "commit", "-m", f"Remove translation files for
deleted component: {name}", "--author", author) is not path-scoped and may
include unrelated staged changes; change the command to explicitly limit the
commit to the removed translation file paths by appending "--" followed by the
list of removed file paths (e.g., a variable like removed_paths or
removed_files) to the args passed to subprocess.run so only those files are
committed (ensure you pass the exact relative paths as arguments after the
"--").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 29945e07-71dd-402e-89f4-18b3aa1b5a2c

📥 Commits

Reviewing files that changed from the base of the PR and between b85bc5f and a825283.

📒 Files selected for processing (10)
  • .env.example
  • src/boost_weblate/endpoint/errors.py
  • src/boost_weblate/endpoint/serializers.py
  • src/boost_weblate/endpoint/services.py
  • src/boost_weblate/endpoint/tasks.py
  • src/boost_weblate/endpoint/views.py
  • tests/endpoint/test_errors.py
  • tests/endpoint/test_serializers.py
  • tests/endpoint/test_services.py
  • tests/endpoint/test_views.py

Comment thread .env.example Outdated
Comment thread src/boost_weblate/endpoint/serializers.py
Comment thread src/boost_weblate/endpoint/services.py
Comment thread src/boost_weblate/endpoint/services.py
@whisper67265 whisper67265 requested a review from henry0816191 June 9, 2026 17:22

@henry0816191 henry0816191 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

docs/boost-endpoint-api.md still documents the old error shapes

@whisper67265 whisper67265 requested a review from wpak-ai June 9, 2026 19:20
@whisper67265

Copy link
Copy Markdown
Collaborator Author

@coderabbitai, resume

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

@wpak-ai wpak-ai merged commit b3a9c8c into cppalliance:develop Jun 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants