Skip to content

Remove dead defaultAppConfigReverseTransform and add round-trip fidelity tests#6953

Draft
ryancbahan wants to merge 1 commit intorcb/extract-webhook-transformfrom
rcb/phase3-roundtrip-cleanup
Draft

Remove dead defaultAppConfigReverseTransform and add round-trip fidelity tests#6953
ryancbahan wants to merge 1 commit intorcb/extract-webhook-transformfrom
rcb/phase3-roundtrip-cleanup

Conversation

@ryancbahan
Copy link
Contributor

@ryancbahan ryancbahan commented Mar 8, 2026

WHY are these changes introduced?

Two cleanup items after completing Phase 2 (Zod transform extraction):

  1. defaultAppConfigReverseTransform in specification.ts is dead code. Every spec that uses createConfigExtensionSpecification provides a transformConfig, so the !transformConfig fallback branch is unreachable. The function also relies on Zod internal APIs (schema._def.shape()) which are undocumented and fragile.

  2. With all three Zod transforms now extracted (extension_directories, scopes, webhooks), there's no systematic documentation of which spec transforms round-trip cleanly and which have known asymmetries. This makes it hard to reason about config fidelity during deploy/pull cycles.

WHAT is this pull request doing?

Dead code removal:

  • Deletes defaultAppConfigReverseTransform and its 25 lines of Zod-internals-based nesting logic
  • Simplifies resolveReverseAppConfigTransform — removes the schema parameter since the unreachable branch that used it is gone

Round-trip fidelity tests for all 9 config specs:

  • branding — exact round-trip
  • app_home — exact round-trip
  • app_access — exact round-trip
  • point_of_sale — exact round-trip
  • app_proxy — known asymmetry: relative URLs become absolute (forward prepends application_url, reverse doesn't strip it back)
  • webhooks — subscriptions intentionally dropped (handled by webhook_subscription spec)
  • webhook_subscription — forward produces flat form, reverse wraps in {webhooks: {subscriptions: [...]}} structure
  • privacy_compliance_webhooks — reverse reconstructs subscriptions from flat URLs, sorted by URI
  • events — reverse strips server-managed identifier field

Each known asymmetry is documented inline in the test with an explanation of why it exists.

How to test your changes?

npx vitest run packages/app/src/cli/models/extensions/specifications/transform/spec-transform-roundtrip.test.ts

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.92% 14500/18373
🟡 Branches 73.26% 7198/9825
🟡 Functions 79.14% 3695/4669
🟡 Lines 79.23% 13697/17287

Test suite run success

3832 tests passing in 1467 suites.

Report generated by 🧪jest coverage report action from 4aee85b

@ryancbahan ryancbahan force-pushed the rcb/phase3-roundtrip-cleanup branch from 714a3d8 to 8a8e57d Compare March 9, 2026 15:38
@ryancbahan ryancbahan force-pushed the rcb/extract-webhook-transform branch from 34aab98 to 2d9c5ca Compare March 9, 2026 16:39
@ryancbahan ryancbahan force-pushed the rcb/phase3-roundtrip-cleanup branch from 8a8e57d to 00322a4 Compare March 9, 2026 16:39
@ryancbahan ryancbahan force-pushed the rcb/extract-webhook-transform branch from 2d9c5ca to 9d40417 Compare March 9, 2026 17:08
@ryancbahan ryancbahan force-pushed the rcb/phase3-roundtrip-cleanup branch from 00322a4 to 65adeee Compare March 9, 2026 17:08
@ryancbahan ryancbahan force-pushed the rcb/extract-webhook-transform branch from 9d40417 to bb7208c Compare March 11, 2026 14:12
@ryancbahan ryancbahan force-pushed the rcb/phase3-roundtrip-cleanup branch from 65adeee to 4aee85b Compare March 11, 2026 14:13
@github-actions
Copy link
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

packages/cli-kit/dist/public/node/toml/codec.d.ts
import { JsonMap } from '../../../private/common/json.js';
export type JsonMapType = JsonMap;
/**
 * Given a TOML string, it returns a JSON object.
 *
 * @param input - TOML string.
 * @returns JSON object.
 */
export declare function decodeToml(input: string): JsonMapType;
/**
 * Given a JSON object, it returns a TOML string.
 *
 * @param content - JSON object.
 * @returns TOML string.
 */
export declare function encodeToml(content: JsonMap | object): string;
packages/cli-kit/dist/public/node/toml/index.d.ts
export type { JsonMapType } from './codec.js';
packages/cli-kit/dist/public/node/toml/toml-file.d.ts
import { JsonMapType } from './codec.js';
/**
 * Thrown when a TOML file cannot be parsed. Includes the file path for context.
 */
export declare class TomlParseError extends Error {
    readonly path: string;
    constructor(path: string, cause: Error);
}
/**
 * General-purpose TOML file abstraction.
 *
 * Provides a unified interface for reading, patching, removing keys from, and replacing
 * the content of TOML files on disk.
 *
 * - `read` populates content from disk
 * - `patch` does surgical WASM-based edits (preserves comments and formatting)
 * - `remove` deletes a key by dotted path (preserves comments and formatting)
 * - `replace` does a full re-serialization (comments and formatting are NOT preserved).
 * - `transformRaw` applies a function to the raw TOML string on disk.
 */
export declare class TomlFile {
    /**
     * Read and parse a TOML file from disk. Throws if the file doesn't exist or contains invalid TOML.
     * Parse errors are wrapped in {@link TomlParseError} with the file path for context.
     *
     * @param path - Absolute path to the TOML file.
     * @returns A TomlFile instance with parsed content.
     */
    static read(path: string): Promise<TomlFile>;
    readonly path: string;
    content: JsonMapType;
    constructor(path: string, content: JsonMapType);
    /**
     * Surgically patch values in the TOML file, preserving comments and formatting.
     *
     * Accepts a nested object whose leaf values are set in the TOML. Intermediate tables are
     * created automatically. Setting a leaf to `undefined` removes it (use `remove()` for a
     * clearer API when deleting keys).
     *
     * @example
     * ```ts
     * await file.patch({build: {dev_store_url: 'my-store.myshopify.com'}})
     * await file.patch({application_url: 'https://example.com', auth: {redirect_urls: ['...']}})
     * ```
     */
    patch(changes: {
        [key: string]: unknown;
    }): Promise<void>;
    /**
     * Remove a key from the TOML file by dotted path, preserving comments and formatting.
     *
     * @param keyPath - Dotted key path to remove (e.g. 'build.include_config_on_deploy').
     * @example
     * ```ts
     * await file.remove('build.include_config_on_deploy')
     * ```
     */
    remove(keyPath: string): Promise<void>;
    /**
     * Replace the entire file content. The file is fully re-serialized — comments and formatting
     * are NOT preserved.
     *
     * @param content - The new content to write.
     * @example
     * ```ts
     * await file.replace({client_id: 'abc', name: 'My App'})
     * ```
     */
    replace(content: JsonMapType): Promise<void>;
    /**
     * Transform the raw TOML string on disk. Reads the file, applies the transform function
     * to the raw text, writes back, and re-parses to keep `content` in sync.
     *
     * Use this for text-level operations that can't be expressed as structured edits —
     * e.g. Injecting comments or positional insertion of keys in arrays-of-tables.
     * Subsequent `patch()` calls will preserve any comments added this way.
     *
     * @param transform - A function that receives the raw TOML string and returns the modified string.
     * @example
     * ```ts
     * await file.transformRaw((raw) => `# Header comment\n${raw}`)
     * ```
     */
    transformRaw(transform: (raw: string) => string): Promise<void>;
    private decode;
}

Existing type declarations

We found no diffs with existing type declarations

@ryancbahan ryancbahan force-pushed the rcb/phase3-roundtrip-cleanup branch from 4aee85b to 742abef Compare March 11, 2026 22:13
@ryancbahan ryancbahan force-pushed the rcb/extract-webhook-transform branch from bb7208c to 0dbbbb9 Compare March 11, 2026 22:13
…ity tests

Delete unreachable defaultAppConfigReverseTransform and its dead code path
in resolveReverseAppConfigTransform. Add round-trip tests for all 9 config
specs documenting forward/reverse transform behavior and known asymmetries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan force-pushed the rcb/extract-webhook-transform branch from 0dbbbb9 to fddb50d Compare March 12, 2026 14:53
@ryancbahan ryancbahan force-pushed the rcb/phase3-roundtrip-cleanup branch from 742abef to 5d2f349 Compare March 12, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant