Skip to content

Allow relative virtual chunks#1765

Merged
paraseba merged 5 commits intomainfrom
push-mwknyxtmllwp
Mar 5, 2026
Merged

Allow relative virtual chunks#1765
paraseba merged 5 commits intomainfrom
push-mwknyxtmllwp

Conversation

@paraseba
Copy link
Collaborator

@paraseba paraseba commented Mar 4, 2026

To use relative urls users need to:

  • Create named virtual chunk containers
  • When they add virtual references use locations with protocol vcc://
  • Make the hostname in the url equal to some VCC name
  • If validate_container=True when they set a virtual ref, and the url is vcc://foo/bar.nc, foo must match some VCC name. The final url will be {foo url prefix}/bar.nc

To use relative urls users need to:

* Create named virtual chunk containers
* When they add virtual references use locations with protocol `vcc://`
* Make the hostname in the url equal to some VCC name
* If validate_container=True when they set a virtual ref, and
  the url is `vcc://foo/bar.nc`, `foo` must match some VCC name.
  The final url will be `{foo url prefix}/bar.nc`
Copy link
Member

@TomNicholas TomNicholas left a comment

Choose a reason for hiding this comment

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

This looks great - I only have one substantive Q (about allowing multiple VCCs with the same name). I think this should meet our requirements.

It would also be nice to have at least like 1 line of docs about this somewhere, now that name actually does something!

}

/// Parse a location that may be either `vcc://` relative or an absolute URL.
pub fn from_url(path: &str) -> Result<VirtualChunkLocation, VirtualReferenceError> {
Copy link
Member

Choose a reason for hiding this comment

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

This method is just for API backwards compatibility?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

basically, yes, but it should work for normal and vcc

Comment on lines +341 to +342
} else if scheme == "vcc" {
return Err(VirtualReferenceErrorKind::NoContainerForName(path.into()).into());
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused - how does ::from_url not also trigger this Err?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If i understand your question correctly: Because you only get here if the url doesn't have a host, which in the case of vcc:// is expected to be the container name

Comment on lines +583 to +584
// Check name uniqueness: if the new container has a name, no existing
// container with the same name should have a different url_prefix
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand how its okay to have two containers with the same name at all. How does IC know which VCC to resolve to?

Copy link
Member

Choose a reason for hiding this comment

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

Okay actually this is just for updating. But it's still confusing - when I overwrite an existing container by setting a new container with the same name as the old one, is that meant to be an overwrite (in which case there should be no restrictions), or are you trying to force me to delete the old container entirely before I can set the new one (in which case two containers with the same name should not be allowed ever).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the issue here is that we have two identities for VCCs and they both need to work for different cases. The url prefix and the name. I changed the approach: if the container you pass here has a name it will be used as the key and replace any other of the same name. If it doesn't have a name, it will use the url prefix as key.

Default::default(),
);

let result = resolver.expand_location("vcc://unknown/chunk.nc");
Copy link
Member

Choose a reason for hiding this comment

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

Might also be worth testing case of

"vcc://chunk.nc"

where there is no name, but it's using a relative protocol.

@paraseba
Copy link
Collaborator Author

paraseba commented Mar 5, 2026

Thanks for the thorough review @TomNicholas , I implemented what you asked for, and I think set_virtual_container is much more intuitive now. I'll merge once tests pass.

@paraseba paraseba merged commit 5f7bbf8 into main Mar 5, 2026
20 checks passed
@paraseba paraseba deleted the push-mwknyxtmllwp branch March 5, 2026 21:42
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.

2 participants