Skip to content

[CDTOOL-1766] Add ContentGuard bot-management commands - #1922

Merged
WhiteAbeLincoln merged 10 commits into
mainfrom
abe/bot-management
Nov 17, 2026
Merged

WhiteAbeLincoln merged 10 commits into
mainfrom
abe/bot-management

Conversation

@WhiteAbeLincoln

@WhiteAbeLincoln WhiteAbeLincoln commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Change summary

Adds commands to configure the new ContentGuard Bot Management feature: https://www.fastly.com/documentation/reference/api/bot-management/

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

Adds commands to configure the new ContentGuard Bot Management feature: https://www.fastly.com/documentation/reference/api/bot-management/

Are there any considerations that need to be addressed for release?

@WhiteAbeLincoln
WhiteAbeLincoln requested a review from a team as a code owner September 29, 2026 17:51
@WhiteAbeLincoln
WhiteAbeLincoln marked this pull request as draft September 29, 2026 17:52
@rcaril
rcaril self-requested a review September 29, 2026 17:55
Comment thread pkg/text/botmanagement.go Resolved
@WhiteAbeLincoln
WhiteAbeLincoln marked this pull request as ready for review September 29, 2026 19:07
@WhiteAbeLincoln
WhiteAbeLincoln removed the request for review from philippschulte September 29, 2026 19:07
@philippschulte philippschulte changed the title feat(bot-management): add ContentGuard bot-management commands [CDTOOL-1766] Add ContentGuard bot-management commands Sep 29, 2026

@philippschulte philippschulte left a comment

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.

Nice work on your first Fastly CLI contribution! 🎉

I didn't find any blocking issues with the implementation.

Great first contribution!

@rcaril

rcaril commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Marking as do-not-merge-yet as we are still waiting on confirmation from the team on how some commands should be designed.

@rcaril rcaril left a comment

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.

Looks great!

A few items around validation below.

Comment thread pkg/commands/botmanagement/bot/list.go Resolved
@WhiteAbeLincoln

Copy link
Copy Markdown
Contributor Author

Instead of adding validation for length in the Exec functions, I decided to add a argparser/validate package which contains reusable functions that can be registered through the Action function when defining a flag. That keeps the checks and the flags co-located, and also means flag registration can be extracted into reusable functions which keep the same invariants.

	c.CmdClause.
		Flag("description", "Description of the workspace").
		Action(c.description.Set).
		Action(validate.LengthBetween(0, 1000)).
		StringVar(&c.description.Value)

I also added non-empty checks for the identifier flags (e.g. --workspace-id, --bot-id, --category-id). go-fastly rejects these in most cases, and the parser will error if the flag is provided without a value, but it does catch cases like --workspace-id="$MY_UNDEFINED_WORKSPACE_ID" and gives a specific remediation instead of an error from the go-fastly api which can't be linked back to the argument that provides the field.

I changed the types of some struct fields from argparser.OptionalString to just string where the empty string isn't a valid value and so can serve the role of missing/not-provided. That meant that I didn't have to check for both c.categoryID.WasSet && c.categoryID.Value != "". I thought this was more natural, but I can revert this though if it's confusing - lots of the codebase uses OptionalString whenever the flag is optional, not just when we have to distinguish "not provided" from "provided but empty".

Comment thread pkg/app/usage.go Resolved
Comment thread pkg/argparser/validate/length.go Resolved
Comment thread pkg/commands/botmanagement/bot/root.go Resolved
Comment thread pkg/argparser/validate/length.go Resolved

@rcaril rcaril left a comment

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.

Thanks for the updates! This should be ready to merge pending the updates around the command design.

@WhiteAbeLincoln

WhiteAbeLincoln commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated with the new --clear-overrides flag for bot-management category update. Also adds a count of overrides of the category's action in the text output for bot-management category get, as discussed with Jessica. The output for --json and category list is unchanged.

Right now this is dependent on an unreleased change in go-fastly to add the patch endpoint for category bots. The go-fastly version needs to be updated to a released version before this is merged.

@WhiteAbeLincoln
WhiteAbeLincoln marked this pull request as draft November 16, 2026 17:43
@WhiteAbeLincoln
WhiteAbeLincoln marked this pull request as ready for review November 16, 2026 21:26
Comment thread pkg/text/botmanagement.go Resolved

@rcaril rcaril left a comment

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.

Two small items above, otherwise looks good!

@rcaril rcaril left a comment

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.

Ship it! 🚢

With the removal of RequestRecorder, some of the test names were
misleading, such as "--service-id filters by service", which can't
actually be asserted since the response is entirely mocked and the
request isn't checked. These have been changed to describe the actual
behavior of the test (generally just parsing arguments and rendering the
response).
Adds checks for workspace name and description length based on the API
spec. Rather than doing this ad-hoc in the Exec function, I added a
reusable `validate` package that provides checks to be added to any
argument through the `Action` function.

Right now this only covers length checks, but future checks could
include (based on ad-hoc checks in the repo):
- regex pattern or "not contains".
  - Used by the dns commands.
- Format/parse checks, like ngwaf thresholds
  - I'd prefer to parse into a new type though, which is awkward for
    Action (but still possible, see OptionalString).
- Cross-flag rules like mutual exclusion, exactly one of, X requires Y.
  - used in logging create commands, s3 and kinesis, TLS commands,
    `bot-management workspace update`
  - Can't go in an `Action`, but maybe on `CmdClause.Validate`
Removes embedded fields pattern,
adds tests for empty id args,
fixes error wording to mention bytes,
fixes duplicate word in comment
@WhiteAbeLincoln
WhiteAbeLincoln merged commit 436505d into main Nov 17, 2026
19 checks passed
@WhiteAbeLincoln
WhiteAbeLincoln deleted the abe/bot-management branch November 17, 2026 17:46
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.

4 participants