Skip to content

Commit 31d19a3

Browse files
committed
Fix binary compatibility for IDataClient and IInstanceClient (#1711)
* Fix binary compatibility for IDataClient and IInstanceClient Adding optional parameters to an interface method causes other packages that depend on Altinn.App.Core to break when calling the method that was changed Also updated AGENTS with some hints - Normal interfaces in Altinn.App.Core must be binary compatible within a major version so that users can have local pacages that still work (never remove a method) - Interfaces marked with the `ImplementableByApps` attribute must not change. * Fix AI suggestions and spelling
1 parent b5e1e8d commit 31d19a3

37 files changed

Lines changed: 1084 additions & 116 deletions

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ We have Architecture Decision Records in the `/doc/adr/` folder.
101101
- Uses **semantic versioning** with MinVer
102102
- Avoid breaking changes (we plan to release major versions yearly. Some breaking changes can be done inbetween but must be manually verified)
103103
- PR titles become release notes
104+
- Normal interfaces in Altinn.App.Core must be binary compatible within a major version so that users can have local packages that still work (never remove a method)
105+
- Interfaces marked with the `ImplementableByApps` attribute must not change.
106+
104107

105108
### Platform Integrations
106109
The libraries integrate with:

src/Altinn.App.Api/Controllers/ActionsController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ public async Task<ActionResult<UserActionResponse>> Perform(
9999
);
100100
}
101101

102-
Instance instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
102+
Instance instance = await _instanceClient.GetInstance(
103+
app,
104+
org,
105+
instanceOwnerPartyId,
106+
instanceGuid,
107+
authenticationMethod: null,
108+
CancellationToken.None
109+
);
103110
if (instance?.Process is null)
104111
{
105112
return Conflict($"Process is not started.");

src/Altinn.App.Api/Controllers/DataController.cs

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -900,14 +900,26 @@ private async Task<ActionResult> GetBinaryData(
900900
DataElement dataElement
901901
)
902902
{
903-
Stream dataStream = await _dataClient.GetBinaryData(instanceOwnerPartyId, instanceGuid, dataGuid);
903+
Stream dataStream = await _dataClient.GetBinaryData(
904+
instanceOwnerPartyId,
905+
instanceGuid,
906+
dataGuid,
907+
authenticationMethod: null,
908+
CancellationToken.None
909+
);
904910

905911
if (dataStream is not null)
906912
{
907913
string? userOrgClaim = User.GetOrg();
908914
if (userOrgClaim is null || !org.Equals(userOrgClaim, StringComparison.OrdinalIgnoreCase))
909915
{
910-
await _instanceClient.UpdateReadStatus(instanceOwnerPartyId, instanceGuid, "read");
916+
await _instanceClient.UpdateReadStatus(
917+
instanceOwnerPartyId,
918+
instanceGuid,
919+
"read",
920+
authenticationMethod: null,
921+
CancellationToken.None
922+
);
911923
}
912924

913925
return File(dataStream, dataElement.ContentType, dataElement.Filename);
@@ -940,7 +952,12 @@ private async Task<ActionResult> GetFormData(
940952
)
941953
{
942954
// Get Form Data from data service. Assumes that the data element is form data.
943-
object appModel = await _dataClient.GetFormData(instance, dataElement);
955+
object appModel = await _dataClient.GetFormData(
956+
instance,
957+
dataElement,
958+
authenticationMethod: null,
959+
CancellationToken.None
960+
);
944961

945962
if (appModel is null)
946963
{
@@ -971,7 +988,13 @@ private async Task<ActionResult> GetFormData(
971988
{
972989
try
973990
{
974-
await _dataClient.UpdateFormData(instance, appModel, dataElement);
991+
await _dataClient.UpdateFormData(
992+
instance,
993+
appModel,
994+
dataElement,
995+
authenticationMethod: null,
996+
CancellationToken.None
997+
);
975998
}
976999
catch (PlatformHttpException e) when (e.Response.StatusCode is HttpStatusCode.Forbidden)
9771000
{
@@ -989,7 +1012,13 @@ private async Task<ActionResult> GetFormData(
9891012
string? userOrgClaim = User.GetOrg();
9901013
if (userOrgClaim is null || !org.Equals(userOrgClaim, StringComparison.OrdinalIgnoreCase))
9911014
{
992-
await _instanceClient.UpdateReadStatus(instanceOwnerId, instanceGuid, "read");
1015+
await _instanceClient.UpdateReadStatus(
1016+
instanceOwnerId,
1017+
instanceGuid,
1018+
"read",
1019+
authenticationMethod: null,
1020+
CancellationToken.None
1021+
);
9931022
}
9941023

9951024
return Ok(appModel);
@@ -1051,7 +1080,9 @@ await GetErrorDetails(
10511080
Request.ContentType,
10521081
contentDispositionHeader.FileName.ToString(),
10531082
dataGuid,
1054-
new MemoryAsStream(bytes)
1083+
new MemoryAsStream(bytes),
1084+
authenticationMethod: null,
1085+
CancellationToken.None
10551086
);
10561087

10571088
SelfLinkHelper.SetDataAppSelfLinks(instanceOwnerPartyId, instanceGuid, dataElement, Request);
@@ -1166,7 +1197,14 @@ private async Task<
11661197
{
11671198
try
11681199
{
1169-
var instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
1200+
var instance = await _instanceClient.GetInstance(
1201+
app,
1202+
org,
1203+
instanceOwnerPartyId,
1204+
instanceGuid,
1205+
authenticationMethod: null,
1206+
CancellationToken.None
1207+
);
11701208
if (instance is null)
11711209
{
11721210
return new ProblemDetails()
@@ -1228,7 +1266,14 @@ IEnumerable<Guid> dataElementGuids
12281266
try
12291267
{
12301268
var application = await _appMetadata.GetApplicationMetadata();
1231-
var instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
1269+
var instance = await _instanceClient.GetInstance(
1270+
app,
1271+
org,
1272+
instanceOwnerPartyId,
1273+
instanceGuid,
1274+
authenticationMethod: null,
1275+
CancellationToken.None
1276+
);
12321277
if (instance is null)
12331278
{
12341279
return new ProblemDetails()
@@ -1292,7 +1337,14 @@ private async Task<
12921337
{
12931338
try
12941339
{
1295-
var instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
1340+
var instance = await _instanceClient.GetInstance(
1341+
app,
1342+
org,
1343+
instanceOwnerPartyId,
1344+
instanceGuid,
1345+
authenticationMethod: null,
1346+
CancellationToken.None
1347+
);
12961348
if (instance is null)
12971349
{
12981350
return new ProblemDetails()

src/Altinn.App.Api/Controllers/DataTagsController.cs

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ public async Task<ActionResult<TagsList>> Get(
6868
[FromRoute] Guid dataGuid
6969
)
7070
{
71-
Instance instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
71+
Instance instance = await _instanceClient.GetInstance(
72+
app,
73+
org,
74+
instanceOwnerPartyId,
75+
instanceGuid,
76+
authenticationMethod: null,
77+
CancellationToken.None
78+
);
7279
if (instance is null)
7380
{
7481
return Problem(
@@ -127,7 +134,14 @@ [FromBody] string tag
127134
);
128135
}
129136

130-
Instance instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
137+
Instance instance = await _instanceClient.GetInstance(
138+
app,
139+
org,
140+
instanceOwnerPartyId,
141+
instanceGuid,
142+
authenticationMethod: null,
143+
CancellationToken.None
144+
);
131145
if (instance is null)
132146
{
133147
return Problem(
@@ -153,7 +167,12 @@ [FromBody] string tag
153167
if (!dataElement.Tags.Contains(tag))
154168
{
155169
dataElement.Tags.Add(tag);
156-
dataElement = await _dataClient.Update(instance, dataElement);
170+
dataElement = await _dataClient.Update(
171+
instance,
172+
dataElement,
173+
authenticationMethod: null,
174+
CancellationToken.None
175+
);
157176
}
158177

159178
TagsList tagsList = new() { Tags = dataElement.Tags };
@@ -191,7 +210,14 @@ public async Task<ActionResult> Delete(
191210
[FromRoute] string tag
192211
)
193212
{
194-
Instance instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
213+
Instance instance = await _instanceClient.GetInstance(
214+
app,
215+
org,
216+
instanceOwnerPartyId,
217+
instanceGuid,
218+
authenticationMethod: null,
219+
CancellationToken.None
220+
);
195221
if (instance is null)
196222
{
197223
return Problem(
@@ -216,7 +242,7 @@ [FromRoute] string tag
216242

217243
if (dataElement.Tags.Remove(tag))
218244
{
219-
await _dataClient.Update(instance, dataElement);
245+
await _dataClient.Update(instance, dataElement, authenticationMethod: null, CancellationToken.None);
220246
}
221247

222248
return NoContent();
@@ -260,7 +286,14 @@ public async Task<ActionResult<SetTagsResponse>> SetTags(
260286
);
261287
}
262288

263-
Instance instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
289+
Instance instance = await _instanceClient.GetInstance(
290+
app,
291+
org,
292+
instanceOwnerPartyId,
293+
instanceGuid,
294+
authenticationMethod: null,
295+
CancellationToken.None
296+
);
264297
if (instance is null)
265298
{
266299
return Problem(
@@ -285,7 +318,12 @@ public async Task<ActionResult<SetTagsResponse>> SetTags(
285318

286319
// Set dataElement tags to be the new tags
287320
dataElement.Tags = [.. tags.Distinct(StringComparer.Ordinal)];
288-
var updatedElement = await _dataClient.Update(instance, dataElement);
321+
var updatedElement = await _dataClient.Update(
322+
instance,
323+
dataElement,
324+
authenticationMethod: null,
325+
CancellationToken.None
326+
);
289327
if (updatedElement is null)
290328
{
291329
return Problem(

src/Altinn.App.Api/Controllers/FileScanController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ public async Task<ActionResult<InstanceFileScanResult>> GetFileScanResults(
4343
[FromRoute] Guid instanceGuid
4444
)
4545
{
46-
Instance instance = await _instanceClient.GetInstance(app, org, instanceOwnerPartyId, instanceGuid);
46+
Instance instance = await _instanceClient.GetInstance(
47+
app,
48+
org,
49+
instanceOwnerPartyId,
50+
instanceGuid,
51+
authenticationMethod: null,
52+
CancellationToken.None
53+
);
4754
if (instance == null)
4855
{
4956
return NotFound();

0 commit comments

Comments
 (0)