<commit_before>package main

import (
	"errors"
	"fmt"
	"path/filepath"
	"regexp"
)

type Stack struct {
	ID string `toml:"id"`
}

type Stacks []Stack

const AnyStack = "any-stack"
const TinyStack = "tiny"

func determineStacks(buildMetadataPath string, dep Dependency, depOrchestratorConfig DependencyOrchestratorConfig) ([]string, error) {
	stackRegexp := regexp.MustCompile(`\/(?:\.|\d)*-(.*)\.json$`)
	matches := stackRegexp.FindStringSubmatch(buildMetadataPath)
	if len(matches) != 2 {
		return nil, errors.New(fmt.Sprintf("expected to find one stack name in filename (%s) but found: %v", filepath.Base(buildMetadataPath), matches[1:]))
	}
	stack := matches[1]

	if stack == AnyStack {
		return handleAnyStack(dep, depOrchestratorConfig)
	} else if stackIsDeprecated(stack, depOrchestratorConfig.DeprecatedStacks) {
		return nil, nil
	}

	for stackName, stackID := range depOrchestratorConfig.V3Stacks {
		if stack == stackName {
			return []string{stackID}, nil
		}
	}
	return nil, errors.New(fmt.Sprintf("%s is not a valid stack", stack))
}

func handleAnyStack(dep Dependency, config DependencyOrchestratorConfig) ([]string, error) {
	var stacks []string
	for stack, stackID := range config.V3Stacks {
		if stack == TinyStack && !includeTiny(dep.ID, config.IncludeTiny) {
			continue
		}
		stacks = append(stacks, stackID)
	}

	if len(stacks) == 0 {
		return nil, errors.New("stack is 'any-stack' but no stacks are configured, check dependency-builds.yml")<commit_msg>Don't error out of update-cnb-dependency if there is an unknown stack, just return nil so it can continue functioning<commit_after>package main

import (
	"errors"
	"fmt"
	"log"
	"path/filepath"
	"regexp"
)

type Stack struct {
	ID string `toml:"id"`
}

type Stacks []Stack

const AnyStack = "any-stack"
const TinyStack = "tiny"

func determineStacks(buildMetadataPath string, dep Dependency, depOrchestratorConfig DependencyOrchestratorConfig) ([]string, error) {
	stackRegexp := regexp.MustCompile(`\/(?:\.|\d)*-(.*)\.json$`)
	matches := stackRegexp.FindStringSubmatch(buildMetadataPath)
	if len(matches) != 2 {
		return nil, errors.New(fmt.Sprintf("expected to find one stack name in filename (%s) but found: %v", filepath.Base(buildMetadataPath), matches[1:]))
	}
	stack := matches[1]

	if stack == AnyStack {
		return handleAnyStack(dep, depOrchestratorConfig)
	} else if stackIsDeprecated(stack, depOrchestratorConfig.DeprecatedStacks) {
		return nil, nil
	}

	for stackName, stackID := range depOrchestratorConfig.V3Stacks {
		if stack == stackName {
			return []string{stackID}, nil
		}
	}
	log.Printf(fmt.Sprintf("%s is not a valid stack", stack))
	return nil, nil
}

func handleAnyStack(dep Dependency, config DependencyOrchestratorConfig) ([]string, error) {
	var stacks []string
	for stack, stackID := range config.V3Stacks {
		if stack == TinyStack && !includeTiny(dep.ID, config.IncludeTiny) {
			continue
		}
		stacks = append(stacks, stackID)
	}

	if len(stacks) == 0 {
		return nil, errors.New("stack is 'any-stack' but no stacks are configured, check dependency-builds.yml")
{'fraction_non_alphanumeric': 0.12842242503259452, 'fraction_numerical': 0.003911342894393742, 'mean_word_length': 5.00587084148728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3937529', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1018, 'n_words': 275}