Skip to content

FlutterGen logs SEVERE when a build.yaml exists without FlutterGen options (config lives in pubspec.yaml) #702

@behnamsattar

Description

@behnamsattar

If a package has a build.yaml for other builders and keeps FlutterGen configuration in pubspec.yaml (as documented), running build_runner prints:

[SEVERE] FlutterGen:
Specified build.yaml as input but the file does not contain valid options, ignoring...

The build then proceeds and succeeds. The message is misleading: nothing is wrong with FlutterGen’s configuration, and build.yaml intentionally does not contain FlutterGen options.

Expected behavior

  • If FlutterGen configuration is in pubspec.yaml, and there is a build.yaml that does not contain FlutterGen options, FlutterGen should:

    • either not read build.yaml at all, or
    • log at INFO/DEBUG (not SEVERE) that it found no FlutterGen options and is using pubspec.yaml.
  • A SEVERE log should be reserved for an actual configuration error (e.g., invalid keys or values in the file that FlutterGen is supposed to read).

Actual behavior

  • FlutterGen emits a SEVERE log line whenever build.yaml is present but doesn’t contain FlutterGen options, even though configuration is valid in pubspec.yaml.
  • This is noisy in CI and can be mistaken for a real error.

Steps to reproduce

  1. Create a Flutter package/app.

  2. Put FlutterGen configuration in pubspec.yaml (example below).

  3. Add a build.yaml at the package root for unrelated builders (e.g., graphql_codegen, go_router_builder), without any FlutterGen section.

  4. Run:

    dart run build_runner build --delete-conflicting-outputs
  5. Observe the SEVERE message from FlutterGen, even though the build succeeds.

pubspec.yaml (relevant part):

flutter_gen:
  output: lib/gen/
  line_length: 80
  integrations:
    flutter_svg: true

build.yaml (example for other builders only):

targets:
  $default:
    builders:
      graphql_codegen:graphql_codegen:
        options:
          clients: [graphql]

global_options:
  go_router_builder:go_router_builder:
    runs_before:
      - graphql_codegen:graphql_codegen

Log excerpt:

[INFO] Generating build script completed, took 151ms
[INFO] Precompiling build script... completed, took 3.0s
[SEVERE] FlutterGen:
Specified build.yaml as input but the file does not contain valid options, ignoring...
[INFO] Building new asset graph completed, took 902ms
...
[INFO] Succeeded after 13.5s with 208 outputs (1246 actions)

Environment

  • flutter_gen_runner: 5.11.0
  • flutter_gen_core: 5.11.0
  • build_runner: 2.4.15
  • Dart SDK: 3.8.x
  • Flutter: 3.32.x
  • OS: macOS 15.6

Impact

  • Causes false‑positive “errors” in local logs and CI.
  • Can trigger CI failure if logs are parsed for error severity.
  • Confuses users into chasing a non‑issue.

Workarounds (not ideal)

  • Add a minimal FlutterGen block to build.yaml just to silence the message:

    targets:
      $default:
        builders:
          flutter_gen_runner:
            options:
              output: lib/gen/

    This defeats the purpose of using pubspec.yaml as the canonical place for FlutterGen config.

  • Ignore the message (noisy in CI).


Suggested fix

  • Detection logic: Only attempt to parse build.yaml for FlutterGen when it contains known FlutterGen keys (e.g., targets.$default.builders.flutter_gen_runner or flutter_gen sections). Otherwise skip quietly.

  • Severity: If you still want to log, downgrade to INFO/DEBUG with wording like:

    “FlutterGen: No FlutterGen options in build.yaml; using pubspec.yaml/defaults.”

  • Docs note: Clarify precedence and that having a build.yaml for other builders is supported and should not produce a severe error.


Additional context

I maintain a build.yaml for other tools (e.g., graphql_codegen, go_router_builder) and keep FlutterGen settings in pubspec.yaml. The configuration is valid, and the build succeeds; only the severity of the log line is problematic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions