Skip to content

Preview a merge

GET
/models/{modelId}/branches/{branchId}/merge-preview
curl --request GET \
--url 'https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/branches/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/merge-preview?source=2489E9AD-2EE2-8E00-8EC9-32D5F69181C0' \
--header 'Authorization: Bearer <token>'

What merging the source branch into this one would come to, computed exactly as the merge computes it up to where it would land or be refused, with nothing written. The answer is one shape either way: conflicts lists every element the merge would refuse, described as a refused merge describes them, and is empty when the merge would land; mergeBaseId, targetCommitId and sourceCommitId are the three commits the preview was computed from, which a merge sent with resolutions is held to as expectedHeadId and expectedSourceHeadId; resolvedNames names what the conflicts name; closureChanges names what the merge would do to the dependencies and metamodel pins of this branch; and blockers lists the message of every rule the merged model would break, each of which the merge answers with that rule’s own problem rather than with a conflict. blockers are listed only for a caller the merge would admit; a caller who may read the model but not merge into it is answered none, since the rules are asked on behalf of whoever would merge. A caller resolves the conflicts from this answer before sending the first merge, rather than from a refusal after it. A read, open to every reader of the model as the compare is, and held to no head: the branches are read as they stand.

modelId
required
string format: uuid
branchId
required
string format: uuid

The branch that would be merged into.

source
required
string format: uuid

The branch that would be merged from, another branch of the same model.

What the merge would come to; nothing was written

Media typeapplication/json

What a merge would come to, computed as the merge computes it and never written: every element it would refuse, described as MergeConflictProblem describes them, or none, the three commits it was computed from, what it would do to the dependencies of the branch it lands on, and every rule the merged model as a whole would break. Every member is always written, so a client reads one shape whether or not there are conflicts.

object
conflicts
required

Every element the merge would refuse, in element-id order; empty when the merge would land as it stands.

Array<object>

One element a merge could not take from either branch, why, and what each branch holds for it: enough to choose a side without reading either branch. The names of the elements its values reference are on the problem’s resolvedNames.

object
elementId
required
string format: uuid
target
required

What the branch merged into holds for the element.

object
present
required

Whether the branch holds the element at all.

boolean
type

The element’s type on that branch, absent when it does not hold the element. An element the two branches hold as different types is resolved by taking one side whole.

string
owners
required

The ids of the elements that own it on that branch, in id order. Empty for the model’s root, and for an element the branch does not hold. Two branches that placed one element under different owners show it here, with nothing among its fields to tell them apart; taking the element from a side places it under that side’s owners. resolvedNames names them.

Array<string>
source
required

What the branch merged from holds for the element.

object
present
required

Whether the branch holds the element at all.

boolean
type

The element’s type on that branch, absent when it does not hold the element. An element the two branches hold as different types is resolved by taking one side whole.

string
owners
required

The ids of the elements that own it on that branch, in id order. Empty for the model’s root, and for an element the branch does not hold. Two branches that placed one element under different owners show it here, with nothing among its fields to tell them apart; taking the element from a side places it under that side’s owners. resolvedNames names them.

Array<string>
fields
required

Every attribute and relation the target’s and the source’s version hold differently, attributes first and each kind by key. A relation counts as held differently when its groups or the ownership of its references differ too, even where its target ids read the same. A side that does not hold the element has no values, so every field the other side holds is listed. Empty when the two versions differ in nothing a field carries, such as their type or their owners alone. A pinned-differently conflict lists the pin alone, as one field, @commitId, or @location for an external dependency, whose values are the pins as a reader names them: the version name where the pin is a release, otherwise Snapshot followed by the first eight characters of the pinned commit’s id, and for an external dependency its document, the address or the name an upload arrived under with the first eight characters of its content’s hash. A pin is taken whole: a resolution taking fields of one takes the side it names for that field, and the target’s where it names none.

Array<object>

One attribute or relation of a conflicting element, as the merge base, the target and the source hold it. A value is absent where that version does not hold the key or the element; a stored empty value reads as absent.

object
key
required

The attribute or relation key, as the element stores it.

string
kind
required

Whether the key is one of the element’s attributes or one of its relations.

string
Allowed values: attribute relation
base

The value at the merge base, absent where the base did not hold the element or the key. Shaped as target is.

Array
target

The value on the branch merged into. An attribute’s value is the list of values it stores; a relation’s is the ids of its targets, group after group, in stored order, which resolvedNames names.

Array
source

The value on the branch merged from, shaped as target is.

Array
managedDependencyChanges

On a pinned-differently conflict on the pin of the model’s metamodel or of one of its extensions only: how many managed dependencies of the branch merged into each side’s pin changes. The built-in elements a pin brings along follow the pin, so they are never conflicts of their own.

object
target
required

How many taking the target’s pin changes, which is none, as they already follow it.

integer
source
required

How many taking the source’s pin changes.

integer
reason
required

both-changed: both branches changed the element, differently. changed-and-deleted: one branch deleted it and the other changed it. owner-deleted: one branch created or changed it under an owner the other deleted, which is also the reason when the other deleted the element together with that owner. target-deleted: one branch changed it while it references an element the other deleted. pinned-differently: the element is a dependency, or the model’s metamodel or extension pin, and the two branches pin it at different commits; taking a side takes that side’s pin, and the dependencies it brings along follow it rather than being reported on their own. dependency-removed: the element refers to content of a dependency the other branch removed, so the merged model would hold a reference nothing resolves; a reference that resolved neither at the merge base nor on either branch was already dangling and is not reported. An element is reported once. An inverse relation is written into both of its ends, so one added on one side to an element the other side changed is both-changed. An owned member added on one side to an owner the other side changed is not: member lists combine, and the owner is both-changed only when both sides changed something other than its member lists, differently.

string
Allowed values: both-changed changed-and-deleted owner-deleted target-deleted pinned-differently dependency-removed
mergeBaseId
required

The common ancestor the two branches were compared against.

string format: uuid
targetCommitId
required

The head of the branch that would be merged into, as the preview read it. A merge with resolutions sends it as expectedHeadId.

string format: uuid
sourceCommitId
required

The head of the branch that would be merged from, as the preview read it. A merge with resolutions sends it as expectedSourceHeadId.

string format: uuid
resolvedNames
required

Display name by element id for every conflicting element, every owner its sides name and every element a relation value of the conflicts names, read as MergeConflictProblem reads them; empty when there are no conflicts.

object
key
additional properties
string
closureChanges
required

Every dependency the merge would add to, remove from or repin on the branch it lands on, by name, then the metamodel pin and each extension pin it would move, one entry each; empty when the dependencies would stay as that branch holds them. Of a merge with conflicts, what it would change with every conflict resolved to the branch it lands on.

Array<object>

One change a merge would make to the dependencies of the branch it lands on. A pin is named as a reader names it: the version name where the pin is a release, and otherwise Snapshot followed by the first eight characters of the pinned commit’s id. An external dependency’s pin is its document: the address it is read from, or the name an upload arrived under followed by the first eight characters of its content’s hash.

object
kind
required

added: the merge adds a dependency the branch does not declare. removed: it removes one the branch declares. repinned: it moves one the branch declares to another pin. metamodel-repinned: it moves the pin of the model’s metamodel. extension-repinned: it moves the pin of one of the model’s metamodel extensions, named by the extension. A dependency the model holds only because another brings it along, and a managed one, follows what is declared and pinned and is never named on its own.

string
Allowed values: added removed repinned metamodel-repinned extension-repinned
name
required

The name of the model depended on, of the document an external dependency reads, or of the metamodel or extension whose pin moves.

string
from

The pin the branch merged into holds. Present on a repin, absent on an addition, and optional on a removal.

string
to

The pin the merge lands. Present on an addition and a repin, absent on a removal.

string
blockers
required

The message of every rule the merged model as a whole would break, such as two namespaces under one prefix; empty when it would break none, and empty for a caller who may not merge into the branch, for whom the rules are not asked. No choice of side resolves one: the merge is refused with that rule’s own problem rather than with MergeConflictProblem, and the remedy is a change on either branch before merging.

Array<string>

Example

{
"conflicts": [
{
"fields": [
{
"kind": "attribute"
}
],
"reason": "both-changed"
}
],
"closureChanges": [
{
"kind": "added"
}
]
}

source is missing or not a uuid, or is this same branch, answered with the plain problem.

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

The model is not the caller’s to read. Or the caller is an agent acting for a person, and the organization that owns the model has not enabled the agent’s AI platform, answered as AgentPlatformNotEnabledProblem.

Media typeapplication/problem+json
Any of:

A Problem answered when an agent acting for a person reached a model whose owning organization has not enabled the AI platform the agent runs on, which its token names. Model content reaches the platform an agent runs on, so the organization decides: until an organization admin turns the platform on in the organization’s AI agent platforms setting, every route on the model refuses the agent, conditional reads and the events stream included, and the model list and every page that names other models leave the organization’s models out. A change of the setting applies to new requests within a minute; an events stream that is already open ends at its token’s expiry, at most ten minutes later.

object
type
required

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string
type
required

Stable constant a client branches on, which is what tells this 403 from the plain one the same routes answer for a model the caller may not read.

string format: uri
Allowed values: https://modeldesk.io/problems/agent-platform-not-enabled

Example

{
"type": "https://modeldesk.io/problems/agent-platform-not-enabled"
}

The model does not exist, answered with the plain problem, or branchId or source names no branch of it, answered as RefNotFoundProblem. A draft is not a branch, so naming one reads as naming nothing.

Media typeapplication/problem+json
Any of:

A Problem answered when a ref the request reads at is not there for the caller, on a resource they may read: a ref id that names nothing, a ref of another resource, and another user’s draft, which reads exactly as a ref that does not exist. The draft routes answer it too when the caller holds no draft.

A 404, as a missing resource is, and told apart from one by its type. A resource the caller cannot read keeps the plain answer it always had, whatever ref was named, so this one never says anything about a resource the caller could not see. To a client it means that the ref it was reading, typically a draft committed or discarded in another session, is gone while the resource stays: it goes back to the branch. The problem names no ref, so the answer for an id that names nothing and for another user’s draft is the same, byte for byte.

object
type
required

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string
type
required

Stable constant a client branches on, which is what tells this 404 from a resource that is missing or not the caller’s to read.

string format: uri
Allowed values: https://modeldesk.io/problems/ref-not-found

Example

{
"type": "https://modeldesk.io/problems/ref-not-found"
}

One of two, told apart by type, each answered as the merge answers it: the source holds nothing this branch does not already have, so there is nothing to preview; or the two heads have several closest common ancestors, after a criss-cross merge, so there is no base to merge over, answered as AmbiguousMergeBaseProblem naming them.

Media typeapplication/problem+json
One of:

A Problem answered when the source branch holds no commit the target does not already have: its head is the merge base of the two. Nothing was written.

object
type
required

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string
type
required

Stable constant a client branches on, which is what tells this 409 from the others a merge answers with.

string format: uri
Allowed values: https://modeldesk.io/problems/nothing-to-merge

Example

{
"type": "https://modeldesk.io/problems/nothing-to-merge"
}

Error

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}