NATS KV icon

NATS KV

Interact with NATS JetStream Key-Value Store - manage buckets and keys

Actions8

Overview

This node interacts with the NATS JetStream Key-Value (KV) Store, allowing users to manage KV buckets and keys within those buckets. Specifically for the Key - History operation, it retrieves the history of changes made to a specific key in a given bucket. This is useful for auditing, debugging, or tracking changes over time to configuration values, user preferences, cached data, or any hierarchical key-value data stored in NATS.

Practical examples include:

  • Retrieving all past versions of a user's settings stored under a key like user.123.settings.
  • Auditing changes to application configuration keys to understand when and how they were modified.
  • Debugging issues by examining the sequence of updates to a cache entry.

Properties

Name Meaning
Bucket Name The name of the KV bucket to operate on. Must contain only letters, numbers, underscores, and hyphens (no spaces or dots). Example: user-preferences, app-config, cache-data.
Key The key to retrieve the history for. Can use dots for hierarchical organization (e.g., user.123.settings). Cannot contain spaces. Example: config.database.host, user.profile.avatar, session.abc123.

Output

The output JSON contains the history of the specified key within the bucket. This typically includes an array of entries representing each version or update made to the key, including metadata such as timestamps, revision numbers, and the stored value at each point in time.

If the node supports binary data output for other operations, it would represent the binary content associated with keys, but for the History operation, the focus is on JSON-formatted historical records.

Dependencies

  • Requires a connection to a NATS JetStream server with access to the KV store feature.
  • Needs an API authentication token or API key credential configured in n8n to establish the connection.
  • Uses bundled NATS client libraries and utility helpers for connection management and validation.

Troubleshooting

  • Invalid Bucket Name: If the bucket name contains invalid characters (spaces, dots), the node will throw a validation error. Ensure bucket names only have letters, numbers, underscores, or hyphens.
  • Unknown Operation or Resource: Errors occur if unsupported operations or resources are specified. Verify that "Key" resource and "History" operation are correctly selected.
  • Connection Issues: Failure to connect to the NATS server due to incorrect credentials or network problems will cause errors. Check API key validity and network accessibility.
  • Key Not Found: If the specified key does not exist in the bucket, the history may be empty or an error might be returned depending on the underlying NATS client behavior.
  • Continue On Fail: If enabled, the node will continue processing subsequent items even if one fails, collecting errors in the output.

Links and References

Discussion