4. The problem is in page [[http://localhost/~USERNAME/ikiwiki_bug_rpc/foo/]] (for instance, [[http://localhost/~USERNAME/ikiwiki_bug_rpc]] is fine.
# Problem
Page `foo` contains the directive ``[[!rpcbug]]`` (`rpcbug` being the name of the plugin). Calling [[``proxy.rpc("srcfile", "bar")``|https://github.com/paternal/ikiwiki-rpcbug/blob/master/plugins/rpcbug#L15]] in the preprocess function seems to mess up the RPC communication between ikiwiki and the plugin, and the result is that the generate `foo/index.html` page is a text file containing the return value of the `preprocess` call.
What I do not understand is that disabling the `format` function (by commenting [[line 46 of the plugin|https://github.com/paternal/ikiwiki-rpcbug/blob/master/plugins/rpcbug#L46]]) solves the problem. Half of an explaination is that I think that when the the ``proxy.rpc`` function is called, the RPC communication is messed up in such a way that the `format` function is not called, and the return value of `preprocess` is considered to be the whole html code of the resulting page.
> I understood that: as the first rpc call messes up the communication, more rpc calls are messed up, but if there is only one rpc call, not that much is broken. -- [[Louis|spalax]]
> I used the debug feature provided with `proxy.py` and rebuilt the wiki. I ran this with [this version](https://github.com/paternal/ikiwiki-rpcbug/tree/b4ba34a8edd1b97989965af69eddac050bc0a8ba) of my minimal bug example.
> * The bug happens in function [preprocess](https://github.com/paternal/ikiwiki-rpcbug/blob/b4ba34a8edd1b97989965af69eddac050bc0a8ba/plugins/rpcbug#L12-17) (in call to [srcfile](https://github.com/paternal/ikiwiki-rpcbug/blob/b4ba34a8edd1b97989965af69eddac050bc0a8ba/plugins/rpcbug#L15), to be more precise).
> * The directive causing the bug is called on page [foo](https://github.com/paternal/ikiwiki-rpcbug/blob/b4ba34a8edd1b97989965af69eddac050bc0a8ba/foo.mdwn).
> * The call to `srcfile(foo)` fails (because Ikiwiki thinks that page `foo` does not exist).
> * Ikiwiki thinks that processing of the directive is finished, whereas the plugin still waits for the answer of Ikiwiki.
> * Ikiwiki asks the plugin to render a new directive, but the plugin interprets the request as the return value for its previous request. Thus, the plugin thinks that `srcfile(foo)` is `page` (this `page` being a misinterpretation of the Ikiwiki request).
> function of the `external` plugin: when the called method fails, it should
> return something (or raise an exception, if this is possible in RPC) to notify
> the plugin that something went wrong.
>
> -- [[Louis|spalax]]
2015-06-29 09:32:42 +02:00
>> Update: This can actually be a [proxy](https://github.com/joeyh/ikiwiki/blob/9c910a76e70111c50ba8cbb518277f809fc1d09d/plugins/proxy.py) error. Indeed:
>>
>> - Ikiwiki sends a `methodCall` message to the plugin (which is a call to the
>> `preprocess` function);
>> - the plugin sends a `methodCall` message to ikiwiki (which is a call to the
>> `srcfile` function);
>> - Ikiwiki answers with a `methodCall` message:
>> - Ikiwiki answers this because the function call failed, and it is already
>> processing the next directive;
>> - the plugin thinks that it is its request answer, and misinterprets it.
>>
>> Thus, I think that the bug is in the `proxy.py` python file. On receiving a
>> `methodCall` (instead of a `methodResponse`) as an answer to a `methodCall`
2015-06-29 09:33:24 +02:00
>> request, `proxy.py` should notice the type of request, and call the requested function.
2015-06-29 09:32:42 +02:00
>>
>> I know Python better than I know Perl, so I can try to fix this.