Skip to content

Fix example secrets for credential fields without a length - #670

Merged
AJaccP merged 1 commit into
mainfrom
aditya/example-secrets-without-length
Sep 23, 2026
Merged

AJaccP merged 1 commit into
mainfrom
aditya/example-secrets-without-length

Conversation

@AJaccP

@AJaccP AJaccP commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Overview

ExampleSecretFromComposition sizes the random part of an example secret as Length - len(prefix) - len(suffix), which assumes Length is always set. It's optional in ValueComposition, and correctly left unset for values that vary in length. With no Length, a field without a prefix produced an empty value, and a field with a prefix produced a negative length that panicked in make([]byte, n). On current main, <plugin>/example-secrets prints blank values for 14 plugins (e.g. Snowflake) and crashes for 11 (e.g. PyPI).

When Length is unset, the value is now built additively: prefix, 24 random characters, then the EXAMPLE suffix when the charset has letters. The random part no longer depends on the prefix, so a long prefix can't consume it. When Length is set, output is unchanged except at the edges: EXAMPLE is only added if at least one random character still fits, and the random part is clamped at zero so a Length shorter than the prefix can't panic. All 61 existing fields that declare a Length still produce exactly that length.

Type of change

  • Created a new plugin
  • Improved an existing plugin
  • Fixed a bug in an existing plugin
  • Improved contributor utilities or experience

Related Issue(s)

How To Test

Unit tests, including regression tests for the reported bug:

go test ./sdk/plugintest/ -v

End to end with the contributor tooling. These printed blank values or panicked before this change, and should now print a full value for every field:

make snowflake/example-secrets
make pypi/example-secrets

These declare a fixed Length and should print values of exactly that length, as before:

make github/example-secrets    # 40 characters
make aws/example-secrets       # 20 and 40 characters

Changelog

<plugin>/example-secrets now generates example values for credential fields without a Length, instead of printing blanks or crashing.

@AJaccP
AJaccP requested a review from JillRegan September 23, 2026 18:19

@JillRegan JillRegan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!!

@AJaccP
AJaccP merged commit fd11644 into main Sep 23, 2026
3 checks passed
@AJaccP
AJaccP deleted the aditya/example-secrets-without-length branch September 23, 2026 18:31
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.

Blank example credential when the field doesn't have a length defined

2 participants