Skip to content

Conversation

@paolodamico
Copy link
Contributor

Stores metadata as S3 metadata object instead of as a separate object in the bucket.

The metadata has a size limit of 2KB. To better accommodate this, the PR:

  • Encodes metadata as CBOR and then compresses it
  • Imposes sensible limits on the number of factors and keys that can be registered per user.

Why?
Enables atomic updates of the backup and metadata.

@paolodamico
Copy link
Contributor Author

Requires #101 to be merged first

.bucket(self.environment.s3_bucket())
.key(get_metadata_key(&backup_metadata.id))
.body(ByteStream::from(serde_json::to_vec(backup_metadata)?))
.metadata("backup-metadata", compressed_metadata)
Copy link
Contributor

Choose a reason for hiding this comment

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

the optional user-defined metadata names must begin with x-amz-meta- to distinguish them from other HTTP headers

let compressed_metadata = result
.metadata
.as_ref()
.and_then(|m| m.get("backup-metadata"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This string is throughout the file, it would be better as a constant.


let encoded_meta = BASE64_STANDARD.encode(&compressed);

if encoded_meta.len() > 2000 {
Copy link
Contributor

Choose a reason for hiding this comment

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

the 2Kb is inclusive of the size of the key, it must be accounted for here too.

@paolodamico paolodamico marked this pull request as draft September 6, 2025 19:57
@paolodamico
Copy link
Contributor Author

leaving this for a later stage.

@paolodamico paolodamico deleted the pd/backup-meta branch September 17, 2025 21:19
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