Skip to content

[DEVEX-707] fix(application init): align with TS config seeding and validation - #126

Merged
jpage-godaddy merged 3 commits into
godaddy:rust-portfrom
qcai-godaddy:DEVEX-707
Jul 17, 2026
Merged

jpage-godaddy merged 3 commits into
godaddy:rust-portfrom
qcai-godaddy:DEVEX-707

Conversation

@qcai-godaddy

Copy link
Copy Markdown
Collaborator

Summary

  • Make init flags optional and seed missing values from --config (write still targets the default env godaddy.toml / .env)
  • Validate required fields and reject non-public url / proxy-url
  • Best-effort config + env file writes after create; include filesWritten in the JSON result
  • Add write_env_file merge helper and is_public_routable_url with unit tests

Test plan

  • cargo build / cargo test / cargo clippy -- -D warnings / cargo fmt --check
  • Manual local test: stubbed createApplication; confirmed flag/config merge, required-field errors, public URL rejection, and filesWritten paths without hitting the real API

@jpage-godaddy jpage-godaddy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Let's check Copilot's reviews as well.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the application init workflow to better align with config seeding/validation behavior by allowing flags to be optional, seeding missing values from an explicit --config, validating required fields (including rejecting non-public URLs), and writing both godaddy.toml and .env (best-effort) while returning filesWritten in the JSON result.

Changes:

  • Add .env path resolution plus a merge/write helper that preserves unrelated .env content while updating GoDaddy-owned keys.
  • Introduce is_public_routable_url and use it during application init to reject localhost/private/link-local style URLs.
  • Update application init output schema/result shape (adds filesWritten, changes returned fields) and add the url crate dependency.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
rust/src/config/mod.rs Adds .env path convention and a merge-based .env writer for app secrets.
rust/src/application/public_url.rs Introduces URL “public routable” validation with unit tests.
rust/src/application/mod.rs Exposes the new public_url module.
rust/src/application/commands/mod.rs Reworks application init flag/config merging, required-field validation, URL validation, and best-effort writes with filesWritten output.
rust/Cargo.toml Adds the url dependency used by the new validator.
rust/Cargo.lock Locks the new url dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/commands/mod.rs Resolved
Comment thread rust/src/application/commands/mod.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Comment on lines +35 to +51
Some(Host::Ipv4(addr)) => {
let octets = addr.octets();
let is_shared = octets[0] == 100 && (64..=127).contains(&octets[1]);
!(octets[0] == 0
|| addr.is_loopback()
|| addr.is_private()
|| addr.is_link_local()
|| is_shared)
}
Some(Host::Ipv6(addr)) => {
let seg0 = addr.segments()[0];
let is_unique_local = (seg0 & 0xfe00) == 0xfc00; // fc00::/7
!(addr.is_loopback()
|| addr.is_unspecified()
|| addr.is_unicast_link_local()
|| is_unique_local)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_global() is unstable (feature(ip)), not usable on our build, use the explicit checks

Comment thread rust/src/application/public_url.rs Resolved
Comment thread rust/src/application/commands/mod.rs Resolved
Comment thread rust/src/application/commands/mod.rs Resolved
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.

3 participants