Skip to content

Commit 4af7feb

Browse files
resolve merge conflicts
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
1 parent 88b3f41 commit 4af7feb

3 files changed

Lines changed: 48 additions & 17 deletions

File tree

internal/services/shared/errors.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,30 @@ func NewDeprecationError(err error) DeprecationError {
7272
}
7373
}
7474

75+
// DeprecationError is an error returned when a schema object or relation is deprecated.
76+
type DeprecationError struct {
77+
error
78+
}
79+
80+
func (err DeprecationError) GRPCStatus() *status.Status {
81+
return spiceerrors.WithCodeAndDetails(
82+
err,
83+
codes.Aborted,
84+
spiceerrors.ForReason(
85+
// TODO: replace with a deprecation type error reason
86+
v1.ErrorReason_ERROR_REASON_SCHEMA_TYPE_ERROR,
87+
map[string]string{},
88+
),
89+
)
90+
}
91+
92+
// NewDeprecationError wraps an error to indicate an attempted write to a deprecated object type, subject or allowed relation type.
93+
func NewDeprecationError(err error) DeprecationError {
94+
return DeprecationError{
95+
error: err,
96+
}
97+
}
98+
7599
// SchemaWriteDataValidationError occurs when a schema cannot be applied due to leaving data unreferenced.
76100
type SchemaWriteDataValidationError struct {
77101
error

pkg/cmd/server/server.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ type Config struct {
124124
MaxLookupResourcesLimit uint32 `debugmap:"visible"`
125125
MaxBulkExportRelationshipsLimit uint32 `debugmap:"visible"`
126126
EnableExperimentalLookupResources bool `debugmap:"visible"`
127-
ExperimentalLookupResourcesVersion string `debugmap:"visible"`
128127
EnableExperimentalRelationshipExpiration bool `debugmap:"visible"`
129128
EnableExperimentalRelationshipDeprecation bool `debugmap:"visible"`
130129
EnableRevisionHeartbeat bool `debugmap:"visible"`
@@ -455,23 +454,22 @@ func (c *Config) Complete(ctx context.Context) (RunnableServer, error) {
455454
}
456455

457456
permSysConfig := v1svc.PermissionsServerConfig{
458-
MaxPreconditionsCount: maxPreconditionCount,
459-
MaxUpdatesPerWrite: c.MaximumUpdatesPerWrite,
460-
MaximumAPIDepth: c.DispatchMaxDepth,
461-
MaxCaveatContextSize: c.MaxCaveatContextSize,
462-
MaxRelationshipContextSize: c.MaxRelationshipContextSize,
463-
MaxDatastoreReadPageSize: c.MaxDatastoreReadPageSize,
464-
StreamingAPITimeout: c.StreamingAPITimeout,
465-
MaxReadRelationshipsLimit: c.MaxReadRelationshipsLimit,
466-
MaxDeleteRelationshipsLimit: c.MaxDeleteRelationshipsLimit,
467-
MaxLookupResourcesLimit: c.MaxLookupResourcesLimit,
468-
MaxBulkExportRelationshipsLimit: c.MaxBulkExportRelationshipsLimit,
469-
DispatchChunkSize: c.DispatchChunkSize,
470-
ExpiringRelationshipsEnabled: c.EnableExperimentalRelationshipExpiration,
471-
CaveatTypeSet: c.DatastoreConfig.CaveatTypeSet,
472-
PerformanceInsightMetricsEnabled: c.EnablePerformanceInsightMetrics,
457+
MaxPreconditionsCount: maxPreconditionCount,
458+
MaxUpdatesPerWrite: c.MaximumUpdatesPerWrite,
459+
MaximumAPIDepth: c.DispatchMaxDepth,
460+
MaxCaveatContextSize: c.MaxCaveatContextSize,
461+
MaxRelationshipContextSize: c.MaxRelationshipContextSize,
462+
MaxDatastoreReadPageSize: c.MaxDatastoreReadPageSize,
463+
StreamingAPITimeout: c.StreamingAPITimeout,
464+
MaxReadRelationshipsLimit: c.MaxReadRelationshipsLimit,
465+
MaxDeleteRelationshipsLimit: c.MaxDeleteRelationshipsLimit,
466+
MaxLookupResourcesLimit: c.MaxLookupResourcesLimit,
467+
MaxBulkExportRelationshipsLimit: c.MaxBulkExportRelationshipsLimit,
468+
DispatchChunkSize: c.DispatchChunkSize,
469+
ExpiringRelationshipsEnabled: c.EnableExperimentalRelationshipExpiration,
473470
DeprecatedRelationshipsAndObjectsEnabled: c.EnableExperimentalRelationshipDeprecation,
474-
EnableExperimentalLookupResources3: c.ExperimentalLookupResourcesVersion == "lr3",
471+
CaveatTypeSet: c.DatastoreConfig.CaveatTypeSet,
472+
PerformanceInsightMetricsEnabled: c.EnablePerformanceInsightMetrics,
475473
}
476474

477475
healthManager := health.NewHealthManager(dispatcher, ds)

pkg/schemadsl/compiler/translator.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,15 @@ func translateSpecificTypeReference(tctx *translationContext, typeRefNode *dslNo
796796
ref.Deprecation = dep
797797
}
798798

799+
// Add the deprecation, if any.
800+
if depChild, err := typeRefNode.Lookup(dslshape.NodeTypeReferenceDeprecatedType); err == nil && depChild.GetType() == dslshape.NodeTypeDeprecation {
801+
dep, err := translateDeprecation(tctx, depChild)
802+
if err != nil {
803+
return nil, err
804+
}
805+
ref.Deprecation = dep
806+
}
807+
799808
if !tctx.skipValidate {
800809
if err := ref.Validate(); err != nil {
801810
return nil, typeRefNode.Errorf("invalid type relation: %w", err)

0 commit comments

Comments
 (0)