<commit_before>package metadata

import (
	"encoding/json"
	"fmt"
	"strings"
)

func Parse(metadata string) (m Metadata, err error) {
	bytes := []byte(metadata)
	if err = json.Unmarshal(bytes, &m); err != nil {
		return
	}

	if m == (Metadata{}) {
		err = fmt.Errorf("Could not find 'AWS::CloudFormation::Init' key in metadata")
		return
	}

	var c Configs
	if err = json.Unmarshal(bytes, &c); err != nil {
		return
	}
	// Bring the map of configs back to the metadata return value
	m.Init.Configs = c.Configs
	// The map of configs should not include a configSets member
	delete(m.Init.Configs, "configSets")<commit_msg>Fix validity test for metadata result<commit_after>package metadata

import (
	"encoding/json"
	"fmt"
	"strings"
)

func Parse(metadata string) (m Metadata, err error) {
	bytes := []byte(metadata)
	if err = json.Unmarshal(bytes, &m); err != nil {
		return
	}

	if m.Init == nil {
		err = fmt.Errorf("Could not find 'AWS::CloudFormation::Init' key in metadata")
		return
	}

	var c Configs
	if err = json.Unmarshal(bytes, &c); err != nil {
		return
	}
	// Bring the map of configs back to the metadata return value
	m.Init.Configs = c.Configs
	// The map of configs should not include a configSets member
	delete(m.Init.Configs, "configSets")
{'fraction_non_alphanumeric': 0.1259904912836767, 'fraction_numerical': 0.0, 'mean_word_length': 3.839080459770115, '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': '4079047', 'n_tokens_mistral': 445, 'n_tokens_neox': 427, 'n_words': 142}