# Maapi\_start\_trans\_in\_trans used in validation callpoint

**URL:** <https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256>\
**Category:** Core Engine and APIs\
**Created:** [November 8, 2022, 12:55pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256 "2022-11-08T12:55:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie.zha](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@charlie.zha](https://dmap-community.ductus.global/u/charlie.zha)\
**Post date:** [November 8, 2022, 12:55pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/1 "2022-11-08T12:55:03Z")

</div>

HI

I would like to check if it is valid operation to use maapi\_start\_trans\_in\_trans in validation callpoint. The idea is to update a field during the time of validation in the transaction. For example encrypt data.

It seems not specified in document, even though we found it works quite well. However, we have concern it will be blocked by confd in coming release.

Here is the description

> The changes in this transaction can be validated by calling `maapi_validate_trans()` with a non-zero value for _`forcevalidation`_, but calling `maapi_apply_trans()` will not do any validation - in either case, the resulting configuration will be validated when the backend transaction is committed to the running data store. Note though that unlike the case with a transaction directly towards a data store, no transaction lock is taken on the underlying data store when doing validation of this type of transaction - **thus it is possible for the contents of the data store to change (due to commit of another transaction) during the validation**.

Thanks

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [November 8, 2022, 4:41pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/2 "2022-11-08T16:41:54Z")

</div>

I am convinced ConfD should not allow a read-write trans-in-trans in the validation callback and it is a bug that it is allowed. Validation callbacks are supposed to be run after all configuration changes have been done, and this effectively allows you to bypass validation. I am not sure how much it is likely that such call is detected and refused in future releases of ConfD, but you should not (mis)use that.

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [November 8, 2022, 5:20pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/3 "2022-11-08T17:20:26Z")

</div>

I should have added that stuff like data encryption can and should be done elsewhere: a set- or transaction-hook, possibly a custom type callback.

---

<div class="post-metadata">

**Author:** ![charlie.zha](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@charlie.zha](https://dmap-community.ductus.global/u/charlie.zha)\
**Post date:** [November 9, 2022, 9:32am UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/4 "2022-11-09T09:32:50Z")

</div>

Hi

Thanks, it sounds reasonable since it sounds anti-pattern to change data in validation phrase. I would like to understand more about this function `maapi_validate_trans()`. It sounds like this should only be used in sethook. which is the only point user can inject callback before validation. Should this be documented more specifically.

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [November 9, 2022, 3:55pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/5 "2022-11-09T15:55:48Z")

</div>

You can use it also in transaction hooks, transforms, action/command callbacks, or your management applications such as the simple one in the misc/maapi\_cli example.

---

<div class="post-metadata">

**Author:** ![charlie.zha](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@charlie.zha](https://dmap-community.ductus.global/u/charlie.zha)\
**Post date:** [November 22, 2022, 7:51pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/6 "2022-11-22T19:51:14Z")

</div>

> [@mvf](#):
>
> applications such as the simple one in the misc/maapi\_cli exampl

Hi

I tried those approaches, but it seems not work well with Data Provider. It seems Confd doesn’t allow both transaction hooks/transforms together with data provider. Because data provider is implemented by another process, I can’t change. I would like to change data before request reaches callbacks for data provider. Is there better way doing it?

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [November 23, 2022, 11:16am UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/7 "2022-11-23T11:16:13Z")

</div>

There is no reason why transforms or set hook would not work in the presence of an external database. A set-hook can even be registered on data that is handled by the data provider, but you still better should avoid modifying the leaf for which you register the hook.

Custom types are completely independent on the underlying database, but they are also somewhat limited in what you can do in their callbacks - in particular, there is no access to the configuration.

---

<div class="post-metadata">

**Author:** ![charlie.zha](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@charlie.zha](https://dmap-community.ductus.global/u/charlie.zha)\
**Post date:** [November 23, 2022, 12:37pm UTC](https://dmap-community.ductus.global/t/maapi-start-trans-in-trans-used-in-validation-callpoint/4256/8 "2022-11-23T12:37:27Z")

</div>

Hi  
You are right. The problem as I can se now is that we would like to modify the leaf for which I register the hook. It went into infinity loop and hang there.
