Skip to content

Validate IPv6 prefix field in VPC create form - #3343

Merged
david-crespo merged 1 commit into
mainfrom
validate-ipv6-prefix
Aug 21, 2026
Merged

Validate IPv6 prefix field in VPC create form#3343
david-crespo merged 1 commit into
mainfrom
validate-ipv6-prefix

Conversation

@david-crespo

@david-crespo david-crespo commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Closes #3339

image

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
console Ready Ready Preview Aug 21, 2026 5:33pm

Request Review

Comment thread app/util/ip.ts
return parseInt(address.split(':', 1)[0], 16)
}

export function validateVpcIpv6Prefix(value: string): string | undefined {

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.

Vpc in the name is deliberate — there are VPC-specific rules here.

Comment thread app/util/ip.spec.ts
])('invalid: %s', (input, message) => {
expect(validateVpcIpv6Prefix(input)).toEqual(message)
})
})

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.

Checked against the Rust logic with the following cargo script:

#!/usr/bin/env -S cargo +nightly -Zscript
---
[dependencies]
oxnet = "=0.1.6"
---

use oxnet::Ipv6Net;
use std::str::FromStr;

fn backend_accepts(value: &str) -> bool {
    Ipv6Net::from_str(value)
        .is_ok_and(|prefix| prefix.is_unique_local() && prefix.width() == 48)
}

fn main() {
    let cases = [
        ("fd00::/48", true),
        ("fd2d:4569:88b2::/48", true),
        ("fd00::1/48", true),
        ("fc00::/48", true),
        ("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/48", true),
        ("nonsense", false),
        ("fd00::", false),
        ("10.0.0.0/8", false),
        ("::/48", false),
        ("fbff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/48", false),
        ("2001:db8::/48", false),
        ("fe00::/48", false),
        ("fd00::/64", false),
        ("fd00::/40", false),
        ("fd00::/129", false),
    ];

    let mismatches: Vec<_> = cases
        .into_iter()
        .filter(|(value, expected)| backend_accepts(value) != *expected)
        .collect();

    if mismatches.is_empty() {
        println!("all {} cases match oxnet 0.1.6", cases.len());
    } else {
        for (value, expected) in mismatches {
            eprintln!("{value}: expected {expected}, got {}", backend_accepts(value));
        }
        std::process::exit(1);
    }
}

@david-crespo
david-crespo merged commit 950767c into main Aug 21, 2026
7 checks passed
@david-crespo
david-crespo deleted the validate-ipv6-prefix branch August 21, 2026 17:55
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.

IPV6 prefix field in VPC form appears to be missing validation

1 participant