Skip to content

feat: type all policy action constants by service#246

Merged
harshavardhana merged 1 commit into
minio:mainfrom
harshavardhana:feat/type-policy-action-consts
Jul 16, 2026
Merged

feat: type all policy action constants by service#246
harshavardhana merged 1 commit into
minio:mainfrom
harshavardhana:feat/type-policy-action-consts

Conversation

@harshavardhana

@harshavardhana harshavardhana commented Jul 16, 2026

Copy link
Copy Markdown
Member

Description

Gives every policy action constant its proper service type — Action,
AdminAction, STSAction, KMSAction, TableAction, VectorsAction,
MemoryAction — instead of an untyped string constant.

Why

ActionType (#245) lets generic helpers accept any typed action. But an
untyped string constant passed to func[T ActionType] infers T = string,
which the union rejects:

string does not satisfy ActionType (string missing in Action | AdminAction | ...)

Typing the constants makes them satisfy the union via inference, so consumers
(MinIO AIStor) can make request-auth helpers like checkRequestAuthType generic
over ActionType and pass typed constants directly — no per-call Action(...).

Changes

  • Every action constant is now explicitly typed by service.
  • Where the base-Action-keyed engine aggregates heterogeneous actions —
    predefined policies (constants.go), implicitActions, and the per-service
    condition-key maps — the typed constants are converted explicitly with
    Action(...). This is the one place the design intentionally unifies on the
    base type; the conversions are explicit and local.

No behavior change. go build ./..., go vet ./..., and go test ./policy/...
pass.

Note

Consumers that used these constants where a bare string is required will need
an explicit string(...)/Action(...) conversion — hence a minor version bump.

Summary by CodeRabbit

  • Refactor

    • Standardized action definitions with explicit action types across policy categories.
    • Improved consistency when constructing and matching policy action sets.
    • Preserved existing action values, permissions, mappings, and policy behavior.
  • Tests

    • Updated policy and action-matching tests to reflect the standardized action handling.

Give every policy action constant its proper service type (Action,
AdminAction, STSAction, KMSAction, TableAction, VectorsAction,
MemoryAction) instead of an untyped string. This lets generic helpers
constrained by ActionType accept any typed action via inference (an
untyped string constant would otherwise infer as `string`, which the
union rejects).

Where the base Action-keyed engine aggregates heterogeneous actions —
the predefined policies in constants.go, implicitActions, and the
per-service condition-key maps — the typed constants are converted
explicitly with Action(...). No behavior change; go build, go vet, and
go test ./policy/... pass.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 45167a97-f02f-4e3d-9e26-f956ff572622

📥 Commits

Reviewing files that changed from the base of the PR and between 839042d and d6571cf.

📒 Files selected for processing (13)
  • policy/action.go
  • policy/actionset.go
  • policy/actionset_test.go
  • policy/admin-action.go
  • policy/constants.go
  • policy/constants_test.go
  • policy/kms-action.go
  • policy/memory-action.go
  • policy/policy_test.go
  • policy/statement_test.go
  • policy/sts-action.go
  • policy/table-action.go
  • policy/vectors-action.go

📝 Walkthrough

Walkthrough

Changes

The policy package now explicitly types exported action constants and consistently converts specialized actions to Action when building mappings, policies, and test expectations. Action values and mapping relationships remain unchanged.

Policy action typing

Layer / File(s) Summary
Explicit action constant types
policy/action.go, policy/admin-action.go, policy/kms-action.go, policy/memory-action.go, policy/sts-action.go, policy/table-action.go, policy/vectors-action.go
Exported action constants receive explicit domain-specific types while retaining their existing values.
Action mappings and default policies
policy/actionset.go, policy/sts-action.go, policy/table-action.go, policy/constants.go
Implicit-action mappings, condition-key maps, and default policy action sets use explicit Action(...) conversions.
Updated action typing tests
policy/*_test.go
Tests update action-set construction, matching, parsed action expectations, and policy comparisons to use explicit Action(...) values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • minio/pkg#236: Updates related S3Tables condition-key and action mapping logic.

Suggested reviewers: klauspost, rraulinio

Poem

I’m a rabbit with typed actions neat,
Hopping through maps in rows so sweet.
Action(...) wraps each little clue,
Constants keep their old values true.
Tests now match with proper care—
A tidy policy burrow there!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: typing policy action constants by service.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@harshavardhana
harshavardhana merged commit 6ac0e36 into minio:main Jul 16, 2026
11 checks passed
@harshavardhana
harshavardhana deleted the feat/type-policy-action-consts branch July 16, 2026 19:29
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.

1 participant