Bug Report Filter Parameter Broken In Obs-service-cargo After 6.0.6

by StackCamp Team 68 views

Introduction

This article addresses a critical bug encountered in the obs-service-cargo tool, specifically affecting its functionality after version 6.0.6. The issue revolves around the filter parameter within the cargo_vendor service, which appears to be malfunctioning in newer versions. This problem was identified while working with the difftastic package on openSUSE Factory. This comprehensive analysis delves into the specifics of the bug, providing a detailed account of the tests conducted, the error messages encountered, and the contrasting behavior observed in older versions. Understanding the root cause and implications of this bug is crucial for developers and maintainers relying on obs-service-cargo for managing Rust dependencies within the Open Build Service (OBS) environment. We will explore the successful and failed scenarios, offering a clear comparison that highlights the problematic changes introduced after version 6.0.6. By documenting this issue thoroughly, we aim to facilitate a swift resolution and prevent potential disruptions in package building processes.

Problem Description

During the routine usage of obs-service-cargo, a bug was discovered in the filter parameter of the cargo_vendor service. This issue surfaces in versions newer than 6.0.6. To illustrate, consider the scenario with the difftastic package in openSUSE Factory. The _service file, which defines how the cargo_vendor service should operate, includes a filter parameter set to true. This setting is intended to enable filtering of vendored dependencies, ensuring that only necessary crates are included in the final package. However, in newer versions of obs-service-cargo, this parameter leads to an unexpected error, disrupting the build process. Specifically, the system interprets the true value as an unexpected argument, causing the cargo_vendor command to fail. This behavior is a stark contrast to the older versions, where the filter parameter functions as expected, allowing for efficient management of Rust dependencies. The implications of this bug are significant, as it can lead to build failures and necessitate manual intervention to resolve dependency issues. Therefore, a thorough examination of the root cause and a timely resolution are essential to maintain the integrity and efficiency of the build process within the OBS environment.

Here's the content of the _service file used for testing:

<services>
  <service name="download_files" mode="manual" />
  <service name="cargo_vendor" mode="manual">
     <param name="srctar">difftastic-*.tar.gz</param>
     <param name="compression">xz</param>
     <param name="update">false</param>
     <param name="filter">true</param>
  </service>
</services>

Failed Run with Current Version

The current version of obs-service-cargo in Factory/TW, specifically obs-service-cargo-7.0.1+git4.gf492aff6b70ec15c54c50bd1800062bdac7c6b0e-1.1.x86_64, exhibits the bug. When running the osc service manualrun command, the cargo_vendor service fails with an error message indicating an unexpected argument true. This error arises because the service incorrectly interprets the filter parameter's boolean value. The command-line output clearly shows that the true value is passed directly as an argument to the cargo_vendor command, which is not the intended behavior. This failure prevents the vendoring process from completing, thereby halting the package build. The error message provides crucial insight into the nature of the bug, highlighting a discrepancy in how the service handles boolean parameters. Understanding this error is essential for diagnosing the underlying issue and devising a solution. The failed run underscores the need for a patch or update to rectify this behavior and restore the proper functioning of the filter parameter. The error message is as follows:

$ osc service manualrun
Running source_service 'download_files' ...
Running source_service 'cargo_vendor' ...
error: unexpected argument 'true' found

Usage: cargo_vendor [OPTIONS] --src <SRC> --outdir <OUTDIR>

For more information, try '--help'.
Aborting: service call failed:  /usr/lib/obs/service/cargo_vendor --srctar difftastic-*.tar.gz --compression xz --update false --filter true --outdir /tmp/openSUSE:Factory/difftastic/tmptygg_ghi.cargo_vendor.service

Successful Run with Older Version

In stark contrast to the failed run with the current version, the older version of obs-service-cargo, specifically 6.0.6-1.x86_64, operates flawlessly. This version, obtained from the openSUSE:Factory repository, correctly interprets the filter parameter in the _service file. When the osc service manualrun command is executed with this version, the cargo_vendor service proceeds without any errors. The output logs provide a detailed trace of the vendoring process, including dependency fetching, lockfile handling, and cargo audit checks. This successful run underscores the regression introduced in later versions, where the filter parameter's functionality is compromised. The logs also offer valuable insights into the normal operation of the cargo_vendor service, which can be used as a reference point for troubleshooting the bug in newer versions. The ability of version 6.0.6 to correctly handle the filter parameter highlights the specific changes in subsequent releases that led to this issue. The successful execution logs are as follows:

$ osc service manualrun
Running source_service 'download_files' ...
Running source_service 'cargo_vendor' ...
2025-07-06T20:19:29.890325Z  INFO cargo_vendor: 🎒 Starting OBS Service Cargo Vendor.
2025-07-06T20:19:29.890333Z  WARN cargo_vendor: ⚠  Cargo Vendor has been rewritten in rust!

This rewrite introduces some small changes to how vendoring functions for your package.

* cargo_config is no longer created - it's part of the vendor.tar now
    * You can safely remove lines related to cargo_config from your spec file

* multiple cargotoml files can be specified and share a single vendor.tar
    * If multiple cargo.toml files are present update does not work. This is a known
      limitation of the process

* cargo_audit is now part of cargo_vendor, meaning you don't have to configure it separately


2025-07-06T20:19:29.890378Z  INFO libroast::utils: βœ… Matched an item: difftastic-0.63.0.tar.gz
2025-07-06T20:19:29.890389Z  INFO libroast::operations::raw: πŸ₯© Starting Raw.
2025-07-06T20:19:29.890394Z  INFO libroast::utils: βœ… Matched an item: difftastic-0.63.0.tar.gz
2025-07-06T20:19:29.890400Z  INFO libroast::operations::raw: mime_type=Gz
2025-07-06T20:19:30.143924Z  INFO libroast::operations::raw: πŸ₯© You have extracted your source at /tmp/.obs-service-cargo-vendorolQif3zqbXKO
2025-07-06T20:19:30.143943Z  INFO obs_service_cargo::vendor: πŸ“¦ Starting Cargo Vendor
2025-07-06T20:19:30.143997Z  INFO obs_service_cargo::cargo_commands: πŸ”’ Lockfile hash before:  output_hash=Hash("d574be5fb4b50fc5a0b08b5513ee47e3b6ebce94325fba8bcc1b316bf7f68789")
2025-07-06T20:19:30.144177Z  WARN obs_service_cargo::cargo_commands: ⚠ Vendor filterer does not support lockfile verification. Your dependencies MIGHT get updated.
2025-07-06T20:19:30.144180Z  INFO obs_service_cargo::cargo_commands: πŸ”“ Adding lockfile. possible_lockfile="/tmp/.obs-service-cargo-vendorolQif3zqbXKO/difftastic-0.63.0/Cargo.lock"
2025-07-06T20:19:30.144184Z  WARN obs_service_cargo::cargo_commands: πŸ˜₯ Disabled update of dependencies. You should enable this for security updates.
2025-07-06T20:19:30.144186Z  INFO obs_service_cargo::cargo_commands: 🫠 Nothing to update.
2025-07-06T20:19:30.144189Z  INFO obs_service_cargo::cargo_commands: 🚝 Attempting to fetch dependencies.
2025-07-06T20:19:30.144190Z  INFO obs_service_cargo::cargo_commands: ‡ Running `cargo fetch`...
2025-07-06T20:19:39.617332Z  INFO obs_service_cargo::cargo_commands: βœ… `cargo fetch` finished!
2025-07-06T20:19:39.617345Z  INFO obs_service_cargo::cargo_commands: πŸ’Ό Fetched dependencies.
2025-07-06T20:19:39.617346Z  INFO obs_service_cargo::cargo_commands: πŸͺ Running `cargo vendor-filterer`...
2025-07-06T20:19:43.312124Z  INFO obs_service_cargo::cargo_commands: πŸ”’ Lockfile hash after:  output_hash=Hash("b1ff2ab88bb4900f5266c673ac34c38517870a466dee6bf9a870f5998c4261a2")
2025-07-06T20:19:43.312138Z  INFO obs_service_cargo::cargo_commands: πŸ”“ Adding lockfile. possible_lockfile="/tmp/.obs-service-cargo-vendorolQif3zqbXKO/difftastic-0.63.0/Cargo.lock"
2025-07-06T20:19:43.312141Z  INFO obs_service_cargo::cargo_commands: πŸ›‘πŸ«₯ Auditing lockfiles...
2025-07-06T20:19:43.313888Z  INFO obs_service_cargo::audit: πŸŽ‰ Cargo audit passed!
2025-07-06T20:19:43.313892Z  INFO obs_service_cargo::cargo_commands: πŸ›‘πŸ™‚ All lockfiles are audited
2025-07-06T20:19:43.313894Z  INFO obs_service_cargo::cargo_commands: πŸͺ `cargo vendor-filterer` finished.
2025-07-06T20:19:43.358537Z  INFO libroast::operations::roast: ❀‍πŸ”₯Starting Roast.
2025-07-06T20:19:43.358564Z  INFO libroast::utils: βœ… Matched an item: /tmp/.vendor_outIjER6Ntnlkta
2025-07-06T20:19:53.415004Z  INFO libroast::operations::roast: πŸ§‘β€πŸ³our new tarball is now in /tmp/openSUSE:Factory/difftastic/tmpwmx27zbk.cargo_vendor.service/vendor.tar.xz
2025-07-06T20:19:53.440804Z  INFO obs_service_cargo::vendor: πŸ“¦ Cargo Vendor finished.
2025-07-06T20:19:53.440812Z  INFO obs_service_cargo::vendor: 🧹 Cleaning up temporary directory...
2025-07-06T20:19:53.515051Z  INFO obs_service_cargo::cli: 🌟 OBS Service Cargo finished.
2025-07-06T20:19:53.515059Z  INFO obs_service_cargo::cli: 🧹 Cleaning up temporary directories...
Running source_service 'download_files' ...

Workaround

A temporary workaround for this issue involves removing the line <param name="filter">true</param> from the _service file. By disabling the filter parameter, the cargo_vendor service can proceed without encountering the unexpected argument error. While this workaround allows the vendoring process to complete, it's important to note that it bypasses the intended filtering functionality. This means that all dependencies will be included in the vendor tarball, potentially increasing its size and build time. Therefore, this workaround should be considered a temporary solution until the underlying bug is resolved. Developers should be aware of the implications of disabling the filter and weigh the trade-offs between build success and optimized dependency management. The workaround provides a practical approach to mitigating the immediate impact of the bug, but a permanent fix is necessary to restore the full functionality of the cargo_vendor service.

Conclusion

In summary, the bug report highlights a critical issue within obs-service-cargo where the filter parameter in the cargo_vendor service is broken in versions newer than 6.0.6. This problem manifests as an unexpected argument error when the filter parameter is set to true, preventing the vendoring process from completing successfully. The contrasting behavior between the current and older versions clearly indicates a regression in functionality. The provided workaround, which involves removing the filter parameter, offers a temporary solution but bypasses the intended filtering capabilities. This bug has significant implications for developers and maintainers relying on obs-service-cargo for managing Rust dependencies within the OBS environment. A timely and effective resolution is crucial to ensure the smooth and efficient build process of Rust packages. The detailed analysis and documented steps in this report serve as a valuable resource for developers working on a fix. Addressing this bug will not only restore the intended functionality of the filter parameter but also enhance the overall reliability and usability of obs-service-cargo.