Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

fix(enterprise-teams): move input validation to schema ValidateDiagFunc#42

Merged
vmvarela merged 5 commits intomasterfrom
enterprise-teams
Mar 20, 2026
Merged

fix(enterprise-teams): move input validation to schema ValidateDiagFunc#42
vmvarela merged 5 commits intomasterfrom
enterprise-teams

Conversation

@vmvarela
Copy link
Copy Markdown
Owner

Summary

  • Remove redundant if teamID != 0 guard in dataSourceGithubEnterpriseTeamRead — the schema already has ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(1)) which rejects zero/negative values at plan time.
  • Remove redundant if teamSlug == "" { return diag.Errorf(...) } fallback — ExactlyOneOf: []string{"slug", "team_id"} already enforces that exactly one of the two fields is provided at plan time.

Errors now surface at plan time instead of apply time, as suggested by reviewer feedback on upstream PR #3008.

Closes #31

Fixes #22

- website/docs/d/enterprise.html.markdown
- website/docs/r/enterprise_organization.html.markdown
…riseTeamOrganizations callers

Closes #29

- Read: handle 404 by clearing state (d.SetId("")) instead of returning error,
  so resources deleted out-of-band are cleanly removed from state.
- Create: handle 404 from pre-existence check as empty assignments and proceed,
  since a new team may not have any assignments yet.
- Delete: already handled correctly — no change needed.

The errors.As check now branches differently in each caller, making the
type assertion effective as the reviewer requested.
)

Fixes #22

- website/docs/d/enterprise.html.markdown
- website/docs/r/enterprise_organization.html.markdown
…riseTeamOrganizations callers (#40)

Closes #29

- Read: handle 404 by clearing state (d.SetId("")) instead of returning error,
  so resources deleted out-of-band are cleanly removed from state.
- Create: handle 404 from pre-existence check as empty assignments and proceed,
  since a new team may not have any assignments yet.
- Delete: already handled correctly — no change needed.

The errors.As check now branches differently in each caller, making the
type assertion effective as the reviewer requested.
Remove redundant runtime checks from dataSourceGithubEnterpriseTeamRead:
- Drop 'if teamID != 0' guard — ValidateDiagFunc(IntAtLeast(1)) already
  rejects zero/negative values at plan time.
- Drop 'if teamSlug == ""' fallback — ExactlyOneOf already enforces that
  exactly one of slug or team_id is provided.

Closes #31
@vmvarela vmvarela added type:bug Something isn't working enterprise-teams Related to the enterprise-teams feature branch labels Mar 20, 2026
@vmvarela vmvarela merged commit 867bc58 into master Mar 20, 2026
4 checks passed
@github-actions github-actions Bot added type:feature New functionality type:docs Documentation only labels Mar 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enterprise-teams Related to the enterprise-teams feature branch type:bug Something isn't working type:docs Documentation only type:feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(enterprise-teams): move input validation to schema ValidateDiagFunc

1 participant