Skip to content

Fix platform resolution: deduplication + cast safety #6

@tsavo-at-pieces

Description

@tsavo-at-pieces

Overview

Two bugs in platform resolution in WorkflowGenerator._buildContext():

Bug 1: Duplicate platforms produce duplicate runner labels

File: lib/src/cli/utils/workflow_generator.dart line 101

platforms: ["macos", "macos-arm64"] both map to macos-latest in _platformRunners, producing ["macos-latest","macos-latest"] in the matrix JSON. GitHub Actions runs both, wasting CI minutes on identical jobs.

Fix: Deduplicate after runner resolution:

final resolvedRunners = platforms.map((p) => _platformRunners[p]!).toSet().toList();

Bug 2: cast<String>() throws TypeError on non-string elements

File: lib/src/cli/utils/workflow_generator.dart line 101

final platforms = platformsRaw.cast<String>().where(...).toList();

cast<String>() returns a lazy view that throws TypeError during iteration if a non-string element exists (e.g., [123, "ubuntu"]). The sub_packages handling on line 124-125 already uses whereType correctly — this is inconsistent.

Fix: Replace cast<String>() with whereType<String>():

final platforms = platformsRaw.whereType<String>().where((p) => _platformRunners.containsKey(p)).toList();

Acceptance Criteria

  • Runner labels are deduplicated after platform → runner mapping
  • validate() warns when duplicate effective runners would result
  • Non-string platform values are safely filtered (not crash)
  • Tests added covering both edge cases

Metadata

Metadata

Labels

P1-highHigh priorityarea/ci-cdCI/CD workflow generationbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions