Skip to content

Report an error when pushing conflicting metadata.#73

Open
plietar wants to merge 1 commit into
mainfrom
conflict-metadata
Open

Report an error when pushing conflicting metadata.#73
plietar wants to merge 1 commit into
mainfrom
conflict-metadata

Conversation

@plietar

@plietar plietar commented Feb 11, 2025

Copy link
Copy Markdown
Member

Our packet IDs are generally assumed to be globally unique, but this is not guaranteed by construction: the ID is not a hash of its contents, and the metadata store is not content-addressed.

This means one could try to upload two different packets to the store with the same ID. Previously, outpack server would accept the second request but skip writing to the file. It is better to detect this situation and to return an HTTP error when it occurs.

Our packet IDs are generally assumed to be globally unique, but this is
not guaranteed by construction: the ID is not a hash of its contents,
and the metadata store is not content-addressed.

This means one could try to upload two different packets to the store
with the same ID. Previously, outpack server would accept the second
request but skip writing to the file. It is better to detect this
situation and to return an HTTP error when it occurs.
@plietar plietar requested a review from richfitz February 11, 2025 12:21
Comment thread src/utils.rs
///
/// Succeeds if the file already exists with identical contents.
/// On the other hand, an AlreadyExists error is returned if the file exists with different contents.
pub fn write_file_idempotent(path: &Path, contents: &[u8]) -> io::Result<()> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't love this name, but I also couldn't find a better one that expresses the idea of detecting conflicts.

Comment thread src/utils.rs
Comment on lines +39 to +41
if fs::read(path)? != contents {
return Err(err);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we ok with end-of-line standardisartion between windows/everyone else here? I can't remember what we do in this case - perhaps we dodge it by spitting everything out on one line first?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

outpack_server doesn't ever do any special processing of newline or anything else. Metadata files are an immutable blob of bytes.

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