Skip to content

Fix getSpecFromDir to handle auto-generated packages without recipe separator#1

Draft
Copilot wants to merge 5 commits intoInheritance/spec_bodyfrom
copilot/fix-d6c8bfc4-115d-4512-a274-b7e80fb42f11
Draft

Fix getSpecFromDir to handle auto-generated packages without recipe separator#1
Copilot wants to merge 5 commits intoInheritance/spec_bodyfrom
copilot/fix-d6c8bfc4-115d-4512-a274-b7e80fb42f11

Conversation

Copy link

Copilot AI commented Sep 9, 2025

The getSpecFromDir function in bits_helpers/utilities.py was failing when processing auto-generated packages that only return a YAML header without the --- recipe separator.

Problem

Auto-generated packages created through the GeneratedPackage class may only return header content (YAML metadata) without a recipe body. The getSpecFromDir function assumed all package content follows the format:

package: name
version: 1.0
---
recipe content here

When auto-generated packages returned only:

package: name  
version: 1.0

The function would fail with: ValueError: not enough values to unpack (expected 2, got 1)

Solution

Modified getSpecFromDir to handle both cases:

# Before (would fail):
header, recipe = d.split("---", 1)

# After (handles both cases):
if "---" in d:
    header, recipe = d.split("---", 1)  
else:
    header = d
    recipe = ""

This allows auto-generated packages to work properly with the from inheritance feature while maintaining full backward compatibility.

Example

With this fix, auto-generated packages can now be used in inheritance scenarios:

# Override spec inheriting from auto-generated package
package: mypackage
from: autogen  # References auto-generated package directory
version: v2.0  # Override auto-generated version

The auto-generated package provides the base specification, and the override spec can modify or extend it as needed.

Testing

  • Added comprehensive unit tests for both auto-generated packages with and without separators
  • Verified backward compatibility with existing regular packages
  • Tested edge cases (multiple separators, empty content, etc.)
  • All existing functionality remains intact

Additional Changes

  • Fixed regex syntax warning by using raw string for the pattern in resolve_spec_data

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@akritkbehera akritkbehera marked this pull request as ready for review September 9, 2025 19:43
Co-authored-by: akritkbehera <84931167+akritkbehera@users.noreply.github.com>
Copilot AI changed the title [WIP] def getSpecFromDir in bits_helpers/utilities.py Is unable to get the header for a auto generated package properly help me get the recipe that gets autogenerated Fix getSpecFromDir to handle auto-generated packages without recipe separator Sep 9, 2025
Copilot AI requested a review from akritkbehera September 9, 2025 19:52
@akritkbehera akritkbehera marked this pull request as draft September 9, 2025 20:05
@akritkbehera akritkbehera force-pushed the Inheritance/spec_body branch 4 times, most recently from 32c70a0 to 10da16c Compare September 15, 2025 16:31
akritkbehera pushed a commit that referenced this pull request Oct 5, 2025
Added support to download pip3
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.

2 participants