Skip to content
Snippets Groups Projects

Catch Toml overwrite error in PythonPoetryLock config file parsing

Merged Leaminn Ma requested to merge fix-tomlrb-overwrite-error-config-file into master

What does this MR do and why?

Background

The Repository X-Ray scans a project's repository for dependency config files and then parses a list of libraries from the file content. The libraries are then included into the code generation prompt to improve code suggestions. This feature was converted from a CI job to an internal Sidekiq job, and is currently rolled out at 100% in #483928 (closed).

This MR

While monitoring the Sidekiq failed job logs, we noticed the following error:

  • json.exception.class: TomlRB::ValueOverwriteError
  • json.exception.message: Key "version" is defined more than once

This error occurs in PythonPoetryLock here when the TOML content contains a duplicate key.

In this MR, we handle the error so that it doesn't bubble up as a Sidekiq job error. Specifically, we:

  • Updated PythonPoetryLock parsing logic so that it catches other errors (not just ParseError).
  • Also did a minor refactor: moved the TOML example in the spec into a fixture file for clarity.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Error reproduced locally with new spec test Spec test passes after change
Screenshot_2024-10-23_at_1.23.36_PM Screenshot_2024-10-23_at_1.27.45_PM

Related to #483928 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Stan Hu approved this merge request

    approved this merge request

  • Stan Hu resolved all threads

    resolved all threads

  • Before you set this MR to auto-merge

    This merge request will progress on pipeline tiers until it reaches the last tier: pipelinetier-3. We will trigger a new pipeline for each transition to a higher tier.

    Before you set this MR to auto-merge, please check the following:

    • You are the last maintainer of this merge request
    • The latest pipeline for this merge request is pipelinetier-3 (You can find which tier it is in the pipeline name)
    • This pipeline is recent enough (created in the last 8 hours)

    If all the criteria above apply, please set auto-merge for this merge request.

    See pipeline tiers and merging a merge request for more details.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading