Skip to content

refactor: validate backup retention days on SQL DB#249

Open
v-alexmoraru wants to merge 5 commits into
microsoft:mainfrom
v-alexmoraru:v-alexmoraru/add-backup-retention-days-sql
Open

refactor: validate backup retention days on SQL DB#249
v-alexmoraru wants to merge 5 commits into
microsoft:mainfrom
v-alexmoraru:v-alexmoraru/add-backup-retention-days-sql

Conversation

@v-alexmoraru

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 10:47
@v-alexmoraru v-alexmoraru requested a review from a team as a code owner June 11, 2026 10:47
@v-alexmoraru v-alexmoraru marked this pull request as draft June 11, 2026 10:48

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds SQLDatabase-specific validation for the properties.backupRetentionDays field when using the fs set command, including a dedicated error message and test coverage.

Changes:

  • Added validate_sql_database_property to enforce backupRetentionDays integer range validation.
  • Integrated SQLDatabase property validation into fs set execution for SQLDatabase items.
  • Added constants and an error message helper, plus unit tests for valid/invalid inputs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_utils/test_fab_cmd_set_utils.py Adds unit tests covering SQLDatabase backupRetentionDays validation scenarios.
src/fabric_cli/utils/fab_cmd_set_utils.py Implements SQLDatabase-specific validator for backupRetentionDays.
src/fabric_cli/errors/common.py Adds a dedicated error message for invalid backupRetentionDays.
src/fabric_cli/core/fab_constant.py Introduces SQLDatabase validation constants (min/max days and property key).
src/fabric_cli/commands/fs/set/fab_fs_set_item.py Hooks SQLDatabase property validation into the set command execution path.

Comment thread src/fabric_cli/utils/fab_cmd_set_utils.py Outdated
Comment thread tests/test_utils/test_fab_cmd_set_utils.py
@v-alexmoraru v-alexmoraru marked this pull request as ready for review June 17, 2026 05:23
Copilot AI review requested due to automatic review settings June 17, 2026 05:23

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Comment thread src/fabric_cli/utils/fab_cmd_set_utils.py Outdated
Comment thread src/fabric_cli/utils/fab_cmd_set_utils.py Outdated
Comment thread tests/test_utils/test_fab_cmd_set_utils.py
Copilot AI review requested due to automatic review settings June 17, 2026 05:37

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment on lines +95 to +136
def validate_sql_database_property(query: str, input_value: str) -> None:
"""Validate SQLDatabase-specific property values.

Args:
query: The property query path being set.
input_value: The input value to validate.

Raises:
FabricCLIError: If the value is invalid for the property.
"""
if query == fab_constant.SQL_DATABASE_BACKUP_RETENTION_PROPERTY:
min_days = fab_constant.SQL_DATABASE_BACKUP_RETENTION_MIN_DAYS
max_days = fab_constant.SQL_DATABASE_BACKUP_RETENTION_MAX_DAYS

try:
try:
value = int(input_value)
except ValueError:
# Fall back to JSON for encoded values like '7' or '"7"'
parsed = json.loads(input_value)
if isinstance(parsed, bool):
raise ValueError("Booleans are not valid integer values")
elif isinstance(parsed, int):
value = parsed
elif isinstance(parsed, str):
value = int(parsed)
else:
raise ValueError("Value must be an integer")

# Validate range
if not min_days <= value <= max_days:
raise ValueError("Out of range")

except (ValueError, TypeError, json.JSONDecodeError):
raise FabricCLIError(
CommonErrors.invalid_backup_retention_days(
str(input_value),
min_days,
max_days,
),
fab_constant.ERROR_INVALID_INPUT,
)
Comment on lines +113 to +120
# Fall back to JSON for encoded values like '7' or '"7"'
parsed = json.loads(input_value)
if isinstance(parsed, bool):
raise ValueError("Booleans are not valid integer values")
elif isinstance(parsed, int):
value = parsed
elif isinstance(parsed, str):
value = int(parsed)
Comment thread tests/test_utils/test_fab_cmd_set_utils.py
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.

2 participants