# Buggy code
def main():
    args = argument_parser()

    ecs_version = read_version(args.ref)
    print("Running generator. ECS version " + ecs_version)

    # default location to save files
    out_dir = "generated"
    docs_dir = "docs"
    if args.out:
        default_dirs = False
        out_dir = os.path.join(args.out, out_dir)
        docs_dir = os.path.join(args.out, docs_dir)
    else:
        default_dirs = True

    ecs_helpers.make_dirs(out_dir)
    ecs_helpers.make_dirs(docs_dir)

    # To debug issues in the gradual building up of the nested structure, insert
    # statements like this after any step of interest.
    # ecs_helpers.yaml_dump('ecs.yml', fields)

    fields = loader.load_schemas(ref=args.ref, included_files=args.include)
    cleaner.clean(fields)
    finalizer.finalize(fields)
    fields = subset_filter.filter(fields, args.subset, out_dir)
    nested, flat = intermediate_files.generate(
        fields, os.path.join(out_dir, "ecs"), default_dirs
    )

    if args.intermediate_only:
        exit()

    csv_generator.generate(flat, ecs_version, out_dir)
    es_template.generate(
        flat, ecs_version, out_dir, args.template_settings, args.mapping_settings
    )
    beats.generate(nested, ecs_version, out_dir)
    if args.include or args.subset:
        exit()

    asciidoc_fields.generate(nested, ecs_version, docs_dir)


# Traceback (ValueError)
$ python scripts/generator.py --ref v1.5.0
Loading schemas from git ref v1.5.0
Running generator. ECS version 1.5.0
Traceback (most recent call last):
File "scripts/generator.py", line 94, in <module>
main()
File "scripts/generator.py", line 44, in main
cleaner.clean(fields)
File "<redacted>/ecs/scripts/schema/cleaner.py", line 23, in clean
visitor.visit_fields(fields, fieldset_func=schema_cleanup, field_func=field_cleanup)
File "<redacted>/ecs/scripts/schema/visitor.py", line 21, in visit_fields
visit_fields(details['fields'],
File "<redacted>/ecs/scripts/schema/visitor.py", line 19, in visit_fields
field_func(details)
File "<redacted>/ecs/scripts/schema/cleaner.py", line 125, in field_cleanup
field_assertions_and_warnings(field)
File "<redacted>/ecs/scripts/schema/cleaner.py", line 168, in field_assertions_and_warnings
single_line_short_description(field)
File "<redacted>/ecs/scripts/schema/cleaner.py", line 189, in single_line_short_description
raise ValueError(msg)
ValueError: Short descriptions must be single line, and under 120 characters (current length: 134).
Offending field or field set: number
Short description:
Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet.

# Fixed code
def main():
    args = argument_parser()

    ecs_version = read_version(args.ref)
    print("Running generator. ECS version " + ecs_version)

    # default location to save files
    out_dir = "generated"
    docs_dir = "docs"
    if args.out:
        default_dirs = False
        out_dir = os.path.join(args.out, out_dir)
        docs_dir = os.path.join(args.out, docs_dir)
    else:
        default_dirs = True

    ecs_helpers.make_dirs(out_dir)
    ecs_helpers.make_dirs(docs_dir)

    # To debug issues in the gradual building up of the nested structure, insert
    # statements like this after any step of interest.
    # ecs_helpers.yaml_dump('ecs.yml', fields)

    fields = loader.load_schemas(ref=args.ref, included_files=args.include)
    cleaner.clean(fields, strict=args.strict)
    finalizer.finalize(fields)
    fields = subset_filter.filter(fields, args.subset, out_dir)
    nested, flat = intermediate_files.generate(
        fields, os.path.join(out_dir, "ecs"), default_dirs
    )

    if args.intermediate_only:
        exit()

    csv_generator.generate(flat, ecs_version, out_dir)
    es_template.generate(
        flat, ecs_version, out_dir, args.template_settings, args.mapping_settings
    )
    beats.generate(nested, ecs_version, out_dir)
    if args.include or args.subset:
        exit()

    asciidoc_fields.generate(nested, ecs_version, docs_dir)